If it develops connections between words like "bar" => "sometimes an obstacle" => "can be ducked", that could explain it.
Like it would have all these attributes for each of those words, or concepts that relate to that word. "bar" has properties like "means multiple things", "often used in jokes", "could be an obstacle". But it must have quite a bit of properties.
I'm not sure how this AI is built internally, but if it works something that has this network of words and concepts that it can have weighted connections to each other, then you could retroactively come up with how the AI could have got to that result.
So user first says that they want a joke to be explained. It adds "joke" as a concept.
Joke has strong network connections to something like "puns", "unexpected punchlines", "absurdity", etc. And then when a joke is presented it will try to find connections with strongest weights and least concepts travelled. Like if it's a pun joke, it will go through all the words and will see that "bar" => "multiple meanings" => "pun" => "joke".
But then is it pre programmed to consider both meanings when it tries to analyse a joke that is a pun or has it somehow learned to come to it on its own?
> But then I told it "It's actually the word "bar" that's being used in the wordplay. The word "duck" there just means evading something" and asked it to explain the joke again
It gave a couple wrong answers and then was told bar is the wordplay. It didn't figure out bar has two meanings on it's own. It was also told duck is meant to mean evade and to try again. I don't agree that it came up with these associations by itself when was fed the knowledge bar has multiple meanings in the joke and duck in this context means evade.
Making that conclusion by itself would have been the only impressive and creative thing I could think of there.
>In the first two lines of the joke, "walk into a bar" is used in the literal sense, as in two men entering a place where drinks are served. However, in the punchline, "bar" is used in the sense of a barrier or obstacle, rather than its literal meaning of a type of establishment.
The literal sense of walking into a bar isn't walking into a drinking establishment, it's walking into a actual bar. The punchline reveals the first 2 walked into a bar and the third one avoided it, no?