我有一个实体列表,如下所示:
["Bluechoice HMO/POS", "Pathway X HMO/PPO", "HMO", "Indemnity/Traditional Health Plan/Standard"]
这不是详尽的列表,还有其他类似的条目
我想从一个文本文件(包含超过30页的信息)中提取这些实体(如果存在的话)。这里的关键是,这个文本文件是使用OCR生成的,因此可能不包含确切的条目。也就是说,例如,它可能有:
"Out of all the entries the user made, BIueChoise HMOIPOS is the most prominent"
注意“BIueChoise HMOIPOS”w.r.t.“Bluechoice HMO/POS”中的拼写错误
我想要那些存在于文本文件中的实体,即使对应的单词不完全匹配
欢迎任何帮助,无论是算法还是方法。非常感谢
您可以通过使用能够近似匹配字符串并确定它们有多相似的算法来实现这一点,比如Levenshtein distance、Hamming distance、Cosine similarity等等
textdistance
是一个模块,它提供了一系列这样的算法供您使用。检查一下here我遇到了类似的问题,我使用
textdistance
解决了这个问题,方法是从文本文件中选取长度等于我需要搜索/提取的字符串的子字符串,然后使用其中一种算法来查看哪个算法解决了我的问题。 对我来说,余弦相似性在筛选出模糊匹配的字符串时,给了我最好的结果75%以您问题中的“Bluechoice HMO/POS”为例,给您一个想法,我将其应用如下:
相关问题 更多 >
编程相关推荐