Open MaxKe99 opened 3 years ago
I am having the same problem, all the same versions with exception being I'm on a Mac.
The error actually has nothing to do with lines 150-151 of document.py as suggested in #36
def get_top_answer(self, question):
return self.get_answers(question=question)[0]
Please leave those lines unchanged. It basically means that there isn't an answer for that question for the text that is being given to the extractor.
I would suggest using try, except, else blocks for each of the questions as shown below to see which question is not being answered.
try:
who_answer = doc.get_top_answer('who').get_parts_as_text()
except IndexError:
print("An answer for 'who' doesn't exist for this piece of text")
else:
print("Who :", who_answer)
Similarly in the example given in parse_single_from_code.py , when you try using the lead or title short which have very little text content you may get the same error. But for text , you will see that all the questions are answered and you don't encounter this error.
Describe the bug I tried to run the example parse_from_newsplease.py. When attempting to extract the top answer for all 6 questions, I receive a list index out of range error, similar to #36. Sadly, his proposed fix does not work in my case.
The error doesn't occur when trying to only extract Who, What and When.
To Reproduce I used the code from parse_from_newsplease.py and added a few lines to extract and print answers for all 6 questions. I installed Giveme5W1H through pip.
Expected behavior
I expected to receive all six answers.
Versions (please complete the following information):