-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #81 from calpoly-csai/cameron_t
working ask endpoint
- Loading branch information
Showing
34 changed files
with
1,390 additions
and
9 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -116,3 +116,4 @@ credentials.json | |
folder_id.txt | ||
settings.yaml | ||
.export_env_vars | ||
auth.json |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from QA import create_qa_mapping, generate_fact_QA | ||
from nimbus_nlp.NIMBUS_NLP import NIMBUS_NLP | ||
|
||
|
||
class Nimbus: | ||
|
||
def __init__(self): | ||
self.qa_dict = create_qa_mapping( | ||
generate_fact_QA("q_a_pairs.csv") | ||
) | ||
|
||
def answer_question(self, question): | ||
ans_dict = NIMBUS_NLP.predict_question(question) | ||
print(ans_dict) | ||
try: | ||
qa = self.qa_dict[ans_dict["question class"]] | ||
except KeyError: | ||
return "I'm sorry, I don't understand. Please try another question." | ||
else: | ||
answer = qa.answer(ans_dict) | ||
if answer is None: | ||
return("I'm sorry, I understand your question but was unable to find an answer. " | ||
"Please try another question.") | ||
else: | ||
return answer | ||
|
||
if __name__ == "__main__": | ||
nimbus = Nimbus() | ||
while True: | ||
question = input("Enter a question: ") | ||
print(nimbus.answer_question(question)) |
Oops, something went wrong.