How do I extract an exact word from text by using python?
<p>I want to calculate how many lines contain a word matched with keywords I chosen. So I coded like this.</p>

<pre><code>  28         for each_keyword in keywords:
  29             if each_keyword in text:
  31                 related_tweet_count += 1
  32                 print "related_tweet_count", related_tweet_count
  33                 print text
</code></pre>

<p>It performed very well. But it has a problem. For example, I have a keyword "flu" then it gives not only "flu" but also "influence". To solve this problem, I searched match word examples and fixed the code like this.</p>

<pre><code>  28         for each_keyword in keywords:
  30             if re.search('\beach_keyword\b', text, re.I):
  31                 related_tweet_count += 1
  32                 print "related_tweet_count", related_tweet_count
  33                 print text
</code></pre>

<p>But it doesn't work. Please help me out!</p>
