2
$\begingroup$

I came up with an NLP-related problem where I have a list of words and a string. My goal is to find any word in the list of words that is related to the given string.

Here is an example.

Suppose a word from the list is healthy. If the string has any of the following words: healthy, healthier, healthiest, not healthy, more healthy, zero healthy, etc., it will be extracted from the string.

Also, I want to judge whether the extracted word/s is/are bearing positive/negative sentiment.

Let me further explain what I mean by using the previous example.

Our word was healthy. So, for instance, if the word found in the string was healthier, then we can say it is bearing positive sentiment with respect to the word healthy. If we find the word not healthy, it is negative with respect to the word healthy.

$\endgroup$
1
$\begingroup$

There are many ways to solve this problem. One way is to apply stemming or lemmatization to reduce your words. Using NLTK's Porter stemmer for example on healthy, healthier, healthiest, not healthy, more healthy, and zero healthy gives:

healthi , healthier , healthiest , not healthi , more healthi , zero healthi

This can help make word comparisons easier.

Sentiment analysis on the phrases will provide positive, neutral, and negative scores. There are a lot of algorithms for doing this but a common one is Valence Aware Dictionary and sEntiment Reasoner (VADER). Here is a recent article with code using NLTK and the VADER lexicon:

The following article also does sentiment analysis using NLTK and includes stemming and lemmatization. Instead of VADER they use a Naive Bayes classifier on a labeled data set of tweets: How To Perform Sentiment Analysis in Python 3 Using the Natural Language Toolkit (NLTK) by Saumik Daityari.

$\endgroup$
1
  • 1
    $\begingroup$ Maybe you can also describe how words should be compared for similarity. $\endgroup$
    – nbro
    Jan 11 at 0:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.