The boy lifted the bat and hit the ball.
In the above sentence, the noun "bat" means the wooden stick. It does not mean bat, the flying mammal, which is also a noun. Using NLP libraries to find the noun version of the definition would still be ambiguous.
How would one go about writing an algorithm that gets the exact definition, given a word, and the sentence it is used in?
I was thinking you could use word2vec, then use autoextend https://arxiv.org/pdf/1507.01127.pdf to differentiate between 2 different lexemes e.g. bat (animal) and bat (wooden stick).
Then the closest cosine distance between the dictionary definition and any of the words of the sentence might indicate the correct definition.
Does this sound correct?