First, please take a look at this. Quiz show https://www.youtube.com/watch?v=m50H_0B78aQ&feature=emb_logo
python
questions = [
'Where is the capital of Japan?',
'Where is the capital of the United States of America?',
'Where is the capital of France?',
'Would you like something to drink?',
'Where is the capital of the United Kingdom?',
'Where is the capital of Republic of Botswana?',
'Where is the capital of Australia?',
'Roise or Noise?'
]
reader = DocumentReader("deepset/bert-base-cased-squad2")
# if you trained your own model using the training cell earlier, you can access it with this:
#reader = DocumentReader("./models/bert/bbu_squad2")
for question in questions:
answer = ""
print(f"Question: {question}")
results = wiki.search(question)
for result in results:
try:
#page = wiki.page(results[0])
page = wiki.page(result)
#print(f"Top wiki result: {page}")
text = page.content
reader.tokenize(question, text)
except:
print('PageError ocurred! Searching another page..')
answer = reader.get_answer()
if len(answer) >0:
print(f"Answer: {answer}\n")
break
else:
print("...")
Now let's start the quiz shoulder tackle.
Question: Where is the capital of Japan?
...
Answer: Tokyo / Heian - kyō ( modern Kyoto ) / Tokyo / Tokyo /
That's the correct answer. I didn't think Heiankyo would come up with the answer either.
Question: Where is the capital of the United States of America?
...
Answer: Washington , D . C . / The District of Columbia /
Is the correct answer.
Question: Where is the capital of France?
Answer: Saint - Denis / Paris / [CLS] Where is the capital of France ? [SEP]toile , while the working - class neighbourhood of the Faubourg Saint - Antoine on the eastern site of the city grew more and more crowded with poor migrant workers from other regions of France . Paris was the centre of an explosion of philosophic and scientific activity known as the Age of Enlightenment . Diderot and d ' Alembert published their Encyclopédie in 1751 , and the Montgolfier Brothers launched the first manned flight in a hot - air balloon on 21 November 1783 , from the gardens of the Château de la Muette . Paris was the financial capital of continental Europe / Paris / Paris / Paris ' 16th arrondissement /
I was asked to fold it up. You answered Saint-Denis. Is it △ who answered Paris in the second place?
Question: Would you like something to drink?
Answer: juice or soda /
Yes, please drink.
Question: Where is the capital of the United Kingdom?
...
Answer: London / London / Edinburgh /
Is the correct answer.
Question: Where is the capital of Republic of Botswana?
Answer: Gaborone / Gaborone /
It's a difficult question, but it's the correct answer.
Question: Where is the capital of Australia?
Answer: Canberra / Canberra / Canberra /
This is also the correct answer.
Question: Noice or Roice?
...
I've been silent. Wikipedia may not have the answer to the fate-changing question.
After all, I didn't know how many points I had accumulated, so let's leave the 10 million yen guy again next week.
I was allowed to reference. Thank you very much. Building a QA System with BERT on Wikipedia Chocolate Planet Channel
Recommended Posts