Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assignment 1 - 0032112635 #14

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions answer.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
import pandas as pd
from transformers.pipelines import pipeline

hg_comp = pipeline('question-answering', model="distilbert-base-uncased-distilled-squad", tokenizer="distilbert-base-uncased-distilled-squad")
hg_comp = pipeline('question-answering', model="bert-large-cased-whole-word-masking-finetuned-squad", tokenizer="bert-large-cased-whole-word-masking-finetuned-squad")

data = pd.read_csv('examples.csv')
data = pd.read_csv('Example_Data - Sheet1.csv')

for idx, row in data.iterrows():
context = row['context']
question = row['question']
answer = hg_comp({'question': question, 'context': context})['answer']
print(answer)
print('The answer to the question "' + question + '" is "' + answer + '"')

#Answers:
#The answer to the question "who won the match sri lanka or india?" is "India"
#The answer to the question "what was the prison called in the green mile?" is "Cold Mountain Penitentiary"
#The answer to the question "what is the widest highway in north america?" is "Highway 401"
#The answer to the question "what makes the center of an atom stable?" is "The closer an electron is to the nucleus, the greater the attractive force"
#The answer to the question "who did holly matthews play in waterloo rd?" is "Leigh-Ann Galloway"