在较大字符串中查找最佳匹配字符串。
find-best-string的Python项目详细描述
查找最佳字符串
说明
在较大字符串中查找最佳匹配字符串。返回第一个匹配项或所有匹配项及其匹配值。
安装
pip install find-best-string
或
pipenv install find-best-string
参数
- 查询-在语料库中查找匹配项的文本字符串。
- corpus-要扫描查询匹配项的文本字符串。
- 通过语料库扫描第一个匹配值的步长。可以看作是一种“扫描分辨率”。不应超过查询的长度。
- flex-最大左/右子串位置调整值。不应超过查询的长度/2。
- 区分大小写-如果为false,则在fid匹配之前将语料库和查询转换为小写。
用法
fromfind_best_stringimportfind_best_stringcorpus="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."query="Ipsum"first_match=find_best_string(query,corpus)