I am writing an algorithm which identifies sentences in given text, split each sentence into words & return these words after some validations.
I want to implement the same with the help of multi threading.
I'm calling my function which deals with each sentence in threading.thread()
for which it throws an error:
AttributeError: 'WordListCorpusReader' object has no attribute '_LazyCorpusLoader__args'
However, there are few blogs which suggest to use "wn.ensure_loaded()
" function.
But python throws an error saying ensure_loaded()
is not defined.
Can someone help me solve this.
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__()
This throws me an error: Attribute error: 'WordNetCorpusReader' object has no attribute '_LazyCorpusLoader__args'
When I try to check wn.ensure_loaded()
, it throws AttributeError: 'module' object has no attribute 'ensure_loaded'
with ref. to : this SO question
Thank You