使用python搜索新闻中的公司名称

使用python搜索新闻中的公司名称,python,string-matching,Python,String Matching,我有一份如下公司的名单 companies = [Advance Auto Parts Inc, AllianceBernstein Holding L.P., AbbVie Inc., Asbury Automotive Group Inc, ABM Industries Incorporated] 我还有每日新闻数据 News = ['news1', 'news2', 'news3'] 现在我想在新闻数据中搜索这些名称,但在新闻中,公司名称不会像上面列表中那样作为完整名称出现。我想这样做

我有一份如下公司的名单

companies = [Advance Auto Parts Inc, AllianceBernstein Holding L.P., AbbVie Inc., Asbury Automotive Group Inc, ABM Industries Incorporated]
我还有每日新闻数据

News = ['news1', 'news2', 'news3']
现在我想在新闻数据中搜索这些名称,但在新闻中,公司名称不会像上面列表中那样作为完整名称出现。我想这样做:

for news in News:
    for company in companies:
        if (company in news): 
            print('do something')
我现在想到的最好的办法是以一种预期会在新闻中被称为的方式记录所有公司的名称,但这将需要很多时间,因为我有数千家公司。
有什么处理这个问题的建议吗?谢谢。

我建议您自己从互联网上获取公司名称列表,然后重新构建您的列表。使用google dorks调整google搜索可能会对你有所帮助

喜欢推杆

list of fortune 500 companies ext:xls

上面谷歌搜索栏中的dork会弹出一些包含列表的xls文件。我认为这仍然需要一些手工操作,但更轻松地尝试首先确定最常见的结尾;e、 g.IncLtd,然后您可以在新闻中搜索Advance Auto Parts Inc和精简版Advance Auto Parts。然后,您可以尝试找出名称中是否有任何其他单词,如Group或字符串,如和Sons

每次使用全名运行新闻搜索功能,然后使用每个剥离版本运行新闻搜索功能

news(company_name):
    stripped_versions = company_name
    stripped_versions += strip(company_name)
    for version in stripped_versions:
        search_news(version)
其中,剥离版本是公司名称的列表,包括剥离版本,例如:[Advance Auto Parts Inc,Advance Auto Parts]


我希望这段伪代码能帮助您解决问题

这不是一个答案,而是一个可能有用的建议:试试谷歌提醒。我为几家公司准备了一套,所以我或多或少都是最新的。