title: How to Find Company Names in Text Using Python
body: <p>I have a list of properly-formatted company names, and I am trying to find when those companies appear in a document. The problem is that they are unlikely to appear in the document <em>exactly</em> as they do in the list. For example, <code>Visa Inc</code> may appear as <code>Visa</code> or <code>American Airlines Group Inc</code> may appear as <code>American Airlines</code>. </p>
  
  <p>How would I go about iterating over the entire contents of the document and then return the properly formatted company name when a close match is found? </p>
  
  <p>I have tried both <code>fuzzywuzzy</code> and <code>difflib.get_close_matches</code>, but the problem is it looks at each individual word rather than clusters of words:</p>
  
  <pre><code>from fuzzywuzzy import process
  from difflib import get_close_matches
  
  company_name = ['American Tower Inc', 'American Airlines Group Inc', 'Atlantic American Corp', 'American International Group']
  
  text = 'American Tower is one company. American Airlines is another while there is also Atlantic American Corp but we cannot forget about American International Group Inc.'
  
  #using fuzzywuzzy
  for word in text.split():
      print('- ' + word+', ', ', '.join(map(str,process.extractOne(word, company_name))))
  
  #using get_close_matches
  for word in text.split():
      match = get_close_matches(word, company_name, n=1, cutoff=.4)
      print(match)
  
  </code></pre>