原来我没有正确阅读文档,并且定义了要使用的参数。
为清楚起见,我粘贴了以下论点:
所有算法都有 2 个接口:
Class with algorithm-specific params for customizing.
Class instance with default params for quick and simple usage.
所有算法都有一些共同的方法:
.distance(*sequences) – calculate distance between sequences.
.similarity(*sequences) – calculate similarity for sequences.
.maximum(*sequences) – maximum possible value for distance and similarity. For any sequence: distance + similarity == maximum.
.normalized_distance(*sequences) – normalized distance between sequences. The return value is a float between 0 and 1, where 0 means equal, and 1 totally different.
.normalized_similarity(*sequences) – normalized similarity for sequences. The return value is a float between 0 and 1, where 0 means totally different, and 1 equal.
最常见的初始化参数:
qval – q-value for split sequences into q-grams. Possible values:
1 (default) – compare sequences by chars.
2 or more – transform sequences to q-grams.
None – split sequences by words.
as_set – for token-based algorithms:
True – t and ttt is equal.
False (default) – t and ttt is different.
https://pypi.org/project/textdistance/