python-Levenshtein AttributeError: module 'Levenshtein' has no attribute 'distance'

网友投稿 1819 2022-08-22

python-Levenshtein AttributeError: module 'Levenshtein' has no attribute 'distance'

今天咋运行程序的时候,出现了下面的错误:

[1/1000][15050/15056] Loss = 85.33192443847656[1/1000][15051/15056] Loss = 85.493408203125[1/1000][15052/15056] Loss = 78.12874603271484[1/1000][15053/15056] Loss = 86.8485107421875[1/1000][15054/15056] Loss = 81.8629150390625[1/1000][15055/15056] Loss = 136.6531219482422decoding0it [00:01, ?it/s]Traceback (most recent call last): File "train.py", line 117, in train(model) File "train.py", line 70, in train cer = eval(model, dev_dataloader) File "train.py", line 103, in eval cer += decoder.cer(trans, ref) / float(len(ref)) File "/home/eric/Documents/SpeechRecognition_MASR/decoder.py", line 58, in cer return Lev.distance(s1, s2)AttributeError: module 'Levenshtein' has no attribute 'distance'

然后发现自己已经装了Levenshtein。

解决方法

pip install python-Levenshtein==0.11.2

我原来的版本是0.12,降了一下版本,然后就不报错了。

测试代码为:

import Levenshtein as levlev.distance('Levenshtein', 'Lenvinsten')

如果正常输出为4的话,说明是正常的。

参考文献

[1].How to import and use python Levenshtein extension on OSX?. ​​https://stackoverflow.com/questions/28172261/how-to-import-and-use-python-levenshtein-extension-on-osx​​

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:python3 zipfile.BadZipFile: File is not a zip file
下一篇:Android 混淆从入门到精通(android studio模拟器运行不了)
相关文章

 发表评论

暂时没有评论,来抢沙发吧~