kiwirafe / xiangsi

中文文本相似度计算器
MIT License
115 stars 21 forks source link

ZeroDivisionError: division by zero #4

Closed xiran210 closed 1 month ago

xiran210 commented 1 year ago

when i run the code that:

import xiangshi as xs
# Simhash
print(xs.simhash(["-", "-"]))
# Minhash
print(xs.minhash(["-", "-"]))

it will cause errors

File "/home/tuxiaobei/.local/lib/python3.8/site-packages/xiangshi/main.py", line 214, in minhash return intersect / total ZeroDivisionError: division by zero

and i use the xiangshi:4.1.0

kiwirafe commented 1 year ago

Yes I have noticed that error, will fix this as soon as I can and update it in the new version. 发现错误了,将在下个版本中修复。

kiwirafe commented 1 month ago

Sorry for the late reply, but this issue has been fixed in version 4.2.0+:

import xiangshi as xs

print(xs.simhash("-", "-")) # Returns 1.0
print(xs.minhash("-", "-")) # Returns 1.0

Note that the input for v4.2.0+ is different (for previous versions the input is a list, while for v4.2.0+ the input are two strings).