Symspell' float'对象没有属性。
from symspellpy import SymSpell, Verbosity
input_term = "diperbakin tertnduk kenaps"
suggestions = sym_spell.lookup_compound(input_term, max_edit_distance=2)
for suggestion in suggestions:
print(suggestion.term)
输出:Diperbaki tertunduk kenapa
,但我想在数据集中应用此代码,但我遇到了此错误
comment = []
for index, row in df.iterrows():
suggestions = sym_spell.lookup_compound(row["Comment"], max_edit_distance=2)
comment.append(suggestions[0].term)
df["Comment"] = comment
df.head()
,此错误
AttributeError Traceback (most recent call last)
<ipython-input-28-3b0edc49798e> in <module>()
1 comment = []
2 for index, row in df.iterrows():
----> 3 suggestions = sym_spell.lookup_compound(row["Comment"], max_edit_distance=2)
4 review.append(suggestions[0].term)
5
1 frames
/usr/local/lib/python3.7/dist-packages/symspellpy/helpers.py in parse_words(phrase, preserve_case, split_by_space)
196 if preserve_case:
197 return re.findall(r"([^\W_]+['’]*[^\W_]*)", phrase)
--> 198 return re.findall(r"([^\W_]+['’]*[^\W_]*)", phrase.lower())
199
200
AttributeError: 'float' object has no attribute 'lower'
i want to correct spell i try this code is work
from symspellpy import SymSpell, Verbosity
input_term = "diperbakin tertnduk kenaps"
suggestions = sym_spell.lookup_compound(input_term, max_edit_distance=2)
for suggestion in suggestions:
print(suggestion.term)
output : diperbaki tertunduk kenapa
but i want to apply this code in my dataset but i got this error
comment = []
for index, row in df.iterrows():
suggestions = sym_spell.lookup_compound(row["Comment"], max_edit_distance=2)
comment.append(suggestions[0].term)
df["Comment"] = comment
df.head()
and this the error
AttributeError Traceback (most recent call last)
<ipython-input-28-3b0edc49798e> in <module>()
1 comment = []
2 for index, row in df.iterrows():
----> 3 suggestions = sym_spell.lookup_compound(row["Comment"], max_edit_distance=2)
4 review.append(suggestions[0].term)
5
1 frames
/usr/local/lib/python3.7/dist-packages/symspellpy/helpers.py in parse_words(phrase, preserve_case, split_by_space)
196 if preserve_case:
197 return re.findall(r"([^\W_]+['’]*[^\W_]*)", phrase)
--> 198 return re.findall(r"([^\W_]+['’]*[^\W_]*)", phrase.lower())
199
200
AttributeError: 'float' object has no attribute 'lower'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论