2022-12-25 17:15:24 +00:00
|
|
|
import sys
|
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
from transformers import pipeline
|
|
|
|
|
|
|
|
sys.path.append(str(Path(__file__).parent.parent.parent) + "/tools/NLP/data")
|
|
|
|
import internet
|
|
|
|
|
|
|
|
qa_model = pipeline("question-answering")
|
2022-12-26 06:07:39 +00:00
|
|
|
question = "Who is Rishi Sunak"
|
|
|
|
a = str(internet.google(question)[0])
|
|
|
|
print(qa_model(question=question, context=a))
|
2022-12-25 17:15:24 +00:00
|
|
|
## {'answer': 'İstanbul', 'end': 39, 'score': 0.953, 'start': 31}
|