Created
December 24, 2021 07:55
-
-
Save Deepayan137/598cd31761165037bc20c38a70b70e49 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import spacy | |
import neuralcoref | |
import re | |
nlp = spacy.load('en') | |
neuralcoref.add_to_pipe(nlp, conv_dict={'Jack Porter': ['man', 'CEO'], 'Cognizer':['company', 'organization']}) | |
history = "" | |
while True: | |
text = input("Enter your text.\n") | |
if text != "exit": | |
if not text.endswith('?') or text.endswith('.'): | |
text = text + '.' | |
# if text.endswith('?'): | |
# text = text.strip('?') + '.' | |
history = history + text + ' ' | |
doc = nlp(history) | |
resolved_utter = doc._.coref_resolved.split('. ')[-1] | |
print(f"History: {history}") | |
print(f"Query: {resolved_utter}") | |
else: | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment