我有一本包含 2 个和 3 个单词短语的字典,我想在 rss 提要中搜索以进行匹配。我抓取 rss 提要,对其进行处理,它们最终以字符串形式出现在名为“文档”的列表中。我想检查下面的字典,如果字典中的任何短语与文本字符串的一部分匹配,我想返回键的值。我不确定解决这个问题的最佳方法。任何建议将不胜感激。
ngramList = {"cash outflows":-1, "pull out":-1,"winding down":-1,"most traded":-1,"steep gains":-1,"military strike":-1,
"resumed operations":+1,"state aid":+1,"bail out":-1,"cut costs":-1,"alleged violations":-1,"under perform":-1,"more than expected":+1,
"pay more taxes":-1,"not for sale":+1,"struck a deal":+1,"cash flow problems":-2}