我有上千个同义词的清单。我也有数以万计的文件,我想搜索这些条款。使用python(或伪代码)实现这一点的有效方法是什么?你知道吗
# this would work for single word synonyms, but there are multiple word synonyms too
synonymSet = set([...])
wordsInDocument = set([...])
synonymsInDocument = synonymSet.intersection(wordsInDocument)
# this would work, but sounds slow
matches = []
for document in documents:
for synonym in synonymSet:
if synonym in document:
matches.append(synonym)
这个问题有没有好的解决办法,还是需要一段时间? 先谢谢你
从同义词列表中构建正则表达式如何:
相关问题 更多 >
编程相关推荐