Answers.Body: <p>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:</p>
  <pre><code>healthi , healthier , healthiest , not healthi , more healthi , zero healthi
  </code></pre>
  <p>This can help make word comparisons easier.</p>
  <p>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:</p>
  <ul>
  <li><a href="https://predictivehacks.com/how-to-run-sentiment-analysis-in-python-using-vader/" rel="nofollow noreferrer">How To Run Sentiment Analysis In Python Using VADER</a> by George Pipis</li>
  </ul>
  <p>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: <a href="https://www.digitalocean.com/community/tutorials/how-to-perform-sentiment-analysis-in-python-3-using-the-natural-language-toolkit-nltk" rel="nofollow noreferrer">How To Perform Sentiment Analysis in Python 3 Using the Natural Language Toolkit (NLTK)</a> by Saumik Daityari.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-01-11T00:34:04.277Z
Answers.Text: Maybe you can also describe how words should be compared for similarity.
Answers.UserDisplayName: nbro
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-01-10T16:39:52.593Z
Answers.LastActivityDate: 2021-01-10T16:55:45.037Z
Answers.LastEditDate: 2021-01-10T16:55:45.037Z
Answers.UserDisplayName: Brian O'Donnell
Body: <p>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.</p>
  <p>Here is an example.</p>
  <p>Suppose a word from the list is <strong>healthy</strong>. 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.</p>
  <p>Also, I want to judge whether the extracted word/s is/are bearing positive/negative sentiment.</p>
  <p>Let me further explain what I mean by using the previous example.</p>
  <p>Our word was <strong>healthy</strong>. So, for instance, if the word found in the string was <strong>healthier</strong>, then we can say it is bearing <strong>positive</strong> sentiment with respect to the word <strong>healthy</strong>. If we find the word <strong>not healthy</strong>, it is <strong>negative</strong> with respect to the word <strong>healthy</strong>.</p>
  
Tags: <natural-language-processing><sentiment-analysis><stemming><lemmatization>
Title: How can I find words in a string that are related to a given word, then associate a sentiment to that found word?
UserDisplayName: Red
ThreadText: # How can I find words in a string that are related to a given word, then associate a sentiment to that found word?
  
  (Asked by: username_0 on 2021-01-10)
  
  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**.
  
  **Tags:** natural-language-processing, sentiment-analysis, stemming, lemmatization
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-01-10. Score: 1 | Accepted answer
  
  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:
  
  * [How To Run Sentiment Analysis In Python Using VADER](https://predictivehacks.com/how-to-run-sentiment-analysis-in-python-using-vader/) by George Pipis
  
  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)](https://www.digitalocean.com/community/tutorials/how-to-perform-sentiment-analysis-in-python-3-using-the-natural-language-toolkit-nltk) by Saumik Daityari.
  
  > **Comments:**
  > **username_2**: Maybe you can also describe how words should be compared for similarity.  
  
  ---
  
  