Search code examples
machine-learningdeep-learningnlpword-embeddinglinguistics

Natural Language Processing techniques for understanding contextual words


Take the following sentence:

I'm going to change the light bulb

The meaning of change means replace, as in someone is going to replace the light bulb. This could easily be solved by using a dictionary api or something similar. However, the following sentences

I need to go the bank to change some currency

You need to change your screen brightness

The first sentence does not mean replace anymore, it means Exchangeand the second sentence, change means adjust.

If you were trying to understand the meaning of change in this situation, what techniques would someone use to extract the correct definition based off of the context of the sentence? What is what I'm trying to do called?

Keep in mind, the input would only be one sentence. So something like:

Screen brightness is typically too bright on most peoples computers.
People need to change the brightness to have healthier eyes.

Is not what I'm trying to solve, because you can use the previous sentence to set the context. Also this would be for lots of different words, not just the word change.

Appreciate the suggestions.

Edit: I'm aware that various embedding models can help gain insight on this problem. If this is your answer, how do you interpret the word embedding that is returned? These arrays can be upwards of 500+ in length which isn't practical to interpret.


Solution

  • What you're trying to do is called Word Sense Disambiguation. It's been a subject of research for many years, and while probably not the most popular problem it remains a topic of active research. Even now, just picking the most common sense of a word is a strong baseline.

    Word embeddings may be useful but their use is orthogonal to what you're trying to do here.

    Here's a bit of example code from pywsd, a Python library with implementations of some classical techniques:

    >>> from pywsd.lesk import simple_lesk
    >>> sent = 'I went to the bank to deposit my money'
    >>> ambiguous = 'bank'
    >>> answer = simple_lesk(sent, ambiguous, pos='n')
    >>> print answer
    Synset('depository_financial_institution.n.01')
    >>> print answer.definition()
    'a financial institution that accepts deposits and channels the money into lending activities'
    

    The methods are mostly kind of old and I can't speak for their quality but it's a good starting point at least.

    Word senses are usually going to come from WordNet.