Matching company names in the news data using Python
<p>I have news dataset which contains almost 10,000 news over the last 3 years.
I also have a list of companies (names of companies) which are registered in NYSE. Now I want to check whether list of company names in the list have appeared in the news dataset or not.
Example:</p>

<pre><code>company Name: 'E.I. du Pont de Nemours and Company'
News: 'Monsanto and DuPont settle major disputes with broad patent-licensing deal, with DuPont agreeing to pay at least $1.75 billion over 10 years for rights to technology for herbicide-resistant soybeans.'
</code></pre>

<p>Now, I can find the news contains company name if the exact company name is in the news but you can see from the above example it is not the case. 
I also tried another way i.e. I took the integral name in the company's full name i.e. in the above example 'Pont' is a word which should be definitely a part of the text when this company name is called. So it worked for majority of the times but then problem occurs in the following example:</p>

<pre><code>Company Name: Ennis, Inc.
News: L D`ennis` Kozlowski, former chief executive convicted of looting nearly $100 million from Tyco International, has emerged into far more modest life after serving six-and-a-half year sentence and probation; Kozlowski, who became ultimate symbol of corporate greed in era that included scandals at Enron and WorldCom, describes his personal transformation and more humble pleasures that have replaced his once high-flying lifestyle.
</code></pre>

<p>Now you can see <code>Ennis</code> is matching with <code>Dennis</code> in the text so it giving irrelevant news results. </p>

<p>Can someone help in telling the right way of doing this ? Thanks.</p>

<p>You can try</p>

<pre><code>  difflib.get_close_matches
</code></pre>

<p>with the full company name.</p>

python python-3.x machine-learning