我使用wordsegment python库对文本进行标记,如下所示:
from wordsegment import load, segment
tweet = 'Sobering stats: 110,000 homes worth $20B in flood-affected areas in Baton Rouge region, #lawx
... via @theadvocatebr'
print(segment(tweet))然而,我遇到了一个奇怪的错误,我无法理解没有修复:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-2-a4734f82b340> in <module>
1 from wordsegment import load, segment
2 tweet = 'Sobering stats: 110,000 homes worth $20B in flood-affected areas in Baton Rouge region, #lawx via @theadvocatebr'
----> 3 print(segment(tweet))
~\Anaconda3\lib\site-packages\wordsegment\__init__.py in segment(self, text)
165 def segment(self, text):
166 "Return list of words that is the best segmenation of `text`."
--> 167 return list(self.isegment(text))
168
169
~\Anaconda3\lib\site-packages\wordsegment\__init__.py in isegment(self, text)
151 for offset in range(0, len(clean_text), size):
152 chunk = clean_text[offset:(offset + size)]
--> 153 _, chunk_words = search(prefix + chunk)
154 prefix = ''.join(chunk_words[-5:])
155 del chunk_words[-5:]
~\Anaconda3\lib\site-packages\wordsegment\__init__.py in search(text, previous)
138 yield (prefix_score + suffix_score, [prefix] + suffix_words)
139
--> 140 return max(candidates())
141
142 # Avoid recursion limit issues by dividing text into chunks, segmenting
ValueError: max() arg is an empty sequence我在Windows 10上使用了以下内容:
对于如何解决这个问题有什么建议吗?是图书馆的窃听器吗?
发布于 2020-03-15 08:18:15
请在“从load段导入加载,段”之后添加"load()“,这对我有效。
https://stackoverflow.com/questions/60261766
复制相似问题