Open HaoXie2022 opened 2 years ago
Hi, digging up this topic since I encountered the same error message when trying to train a Snowball parser. Candidates are proposed but when typing an answer, no matter what I write I get this :
Traceback (most recent call last):
File "~/New_parser.py", line 64, in <module>
snowball.train(corpus='~/Documents/SB_Training/')
File "~/chemdataextractor/relex/snowball.py", line 184, in train
self.train_from_file(f)
File "~/chemdataextractor/relex/snowball.py", line 206, in train_from_file
if self.train_from_document(d):
File "~/chemdataextractor/relex/snowball.py", line 227, in train_from_document
if self.train_from_sentence(s):
File "~/chemdataextractor/relex/snowball.py", line 240, in train_from_sentence
candidate_relationships = self.candidates(s.tokens)
File "~/chemdataextractor/relex/snowball.py", line 372, in candidates
entities_dict[k].pop(p)
IndexError: pop index out of range
If you have any solution, I would be glad ! Thanks :)
Hmmm I don't have much experience with Snowball myself, I've sent a message to someone in the group who does; I'll let you know once I get more information!
Hi, digging up this topic since I encountered the same error message when trying to train a Snowball parser. Candidates are proposed but when typing an answer, no matter what I write I get this :
Traceback (most recent call last): File "~/New_parser.py", line 64, in <module> snowball.train(corpus='~/Documents/SB_Training/') File "~/chemdataextractor/relex/snowball.py", line 184, in train self.train_from_file(f) File "~/chemdataextractor/relex/snowball.py", line 206, in train_from_file if self.train_from_document(d): File "~/chemdataextractor/relex/snowball.py", line 227, in train_from_document if self.train_from_sentence(s): File "~/chemdataextractor/relex/snowball.py", line 240, in train_from_sentence candidate_relationships = self.candidates(s.tokens) File "~/chemdataextractor/relex/snowball.py", line 372, in candidates entities_dict[k].pop(p) IndexError: pop index out of range
If you have any solution, I would be glad ! Thanks :)
I found that adding a print statement for the list in snowball.py solves this problem (not sure why though!). Here's the updated section:
if len(entities_dict[k]) > 1:
to_pop = []
for i in range(len(entities)):
for j in range(i+1, len(entities)):
if entities[i].start == entities[j].start:
to_pop.append([i, j][np.argmin([entities[i].end, entities[j].end])])
print(to_pop)
Edit: This is not a permanent solution. It works with the example set of papers but fails on other papers. I managed to get past it by using a try-except loop.
I opened examples\using_snowball.ipynb in vscode and encountered an IndexError:pop index out of range when I run to the following code.I was wondering if you could offer some advice.
The following has been output on the screen.