Tout d'abord, jetez un œil à ceci. Spectacle de quiz 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("...")
Maintenant, commençons le tacle d'épaule de quiz.
Question: Where is the capital of Japan?
...
Answer: Tokyo / Heian - kyō ( modern Kyoto ) / Tokyo / Tokyo /
C'est la bonne réponse. Je ne pensais pas non plus qu'Heiankyo trouverait la réponse.
Question: Where is the capital of the United States of America?
...
Answer: Washington , D . C . / The District of Columbia /
Est la bonne réponse.
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 /
On m'a demandé de le plier. Vous avez répondu Saint-Doni. Est-ce △ qui a répondu à Paris en second lieu?
Question: Would you like something to drink?
Answer: juice or soda /
Oui, veuillez boire.
Question: Where is the capital of the United Kingdom?
...
Answer: London / London / Edinburgh /
Est la bonne réponse.
Question: Where is the capital of Republic of Botswana?
Answer: Gaborone / Gaborone /
C'est une question difficile, mais c'est la bonne réponse.
Question: Where is the capital of Australia?
Answer: Canberra / Canberra / Canberra /
C'est aussi la bonne réponse.
Question: Noice or Roice?
...
J'ai gardé le silence. Wikipédia n'a peut-être pas la réponse à la question qui change le destin.
Après tout, je ne savais pas combien de points j'avais accumulés, alors laissons à nouveau le gars de 10 millions de yens la semaine prochaine.
J'ai été autorisé à faire référence. Merci beaucoup. Building a QA System with BERT on Wikipedia Chocolate Planet Channel
Recommended Posts