【发布时间】:2017-04-19 08:06:39
【问题描述】:
我有一个文本文件,其中有多行包含对象的详细信息。我想找到每个字符串的分数,并想检查哪个字符串与用户输入更相关。 例如。文本文件包含
This is not a blue car
Blue or black car is here
This is red car
Red car is here
用户输入是红色汽车。
如何找到最相关的字符串? 所以输出是按相关性排序的,看起来像这样
This is red car
Red car is here
This is not a blue car
Blue or black car is here
【问题讨论】:
-
您可能正在搜索类似Edit Distance
-
欢迎来到 SO。你能告诉我们你到目前为止尝试过的代码吗?
-
"输出按相关性排序",你应该先定义相关性
-
您需要一个使用相似性度量进行搜索的文本索引。 Okapi BM25 就是这样一种相似性度量。也许有更新更好的。你得看看自己。
-
我如何定义相关性
标签: python algorithm python-2.7 search full-text-indexing