我正在编写一个算法,它可以识别给定文本中的句子,将每个句子拆分成单词并在经过一些验证后返回这些单词。
我想在多线程的帮助下实现同样的功能。
我正在调用处理每个句子的函数threading.thread()
它会抛出一个错误:
AttributeError: 'WordListCorpusReader' object has no attribute '_LazyCorpusLoader__args'
然而,很少有博客建议使用“wn.ensure_loaded()
“ 功能。
但是 python 抛出一个错误说ensure_loaded()
没有定义。
有人可以帮我解决这个问题吗?
EDIT:
text = "This is my sample text. I want to break it into sentences"
sentences=(re.split(r"(?<!\w\.\w.)(?<![A-Z][a-z]\.)(?<=\.|\?)\s",text))
wn.ensure_loaded()
co = CoOccurence() #CoOccurence is a class in my package which will work on the sentences
for sentence in sentences:
t = Thread(target=co.__prepareHash__, args=(sentence,)) #co.__prepareHash__ is an other method which works around the sentences
threads.append(t)
t.start()
flag =1
while (flag):
flag = __isThreadAlive__()
这给我一个错误:Attribute error: 'WordNetCorpusReader' object has no attribute '_LazyCorpusLoader__args'
当我尝试检查时wn.ensure_loaded()
,它抛出AttributeError: 'module' object has no attribute 'ensure_loaded'
与参考号。到 :这个问题 https://stackoverflow.com/questions/27433370/what-would-cause-wordnetcorpusreader-to-have-no-attribute-lazycorpusloader
谢谢