fixed question recording with else - exit program
This commit is contained in:
parent
98c9444338
commit
837ac970a6
2 changed files with 31 additions and 17 deletions
|
|
@ -4,7 +4,5 @@ test
|
||||||
test2
|
test2
|
||||||
test123
|
test123
|
||||||
Testing exit code
|
Testing exit code
|
||||||
|
boo
|
||||||
|
test
|
||||||
|
|
||||||
|
|
||||||
44
main.py
44
main.py
|
|
@ -2,18 +2,34 @@ import json
|
||||||
import sys
|
import sys
|
||||||
print("Hello, I am a question answering bot.\n")
|
print("Hello, I am a question answering bot.\n")
|
||||||
question = str(input("Please enter a question, and press the ENTER key:\n"))
|
question = str(input("Please enter a question, and press the ENTER key:\n"))
|
||||||
if question.isalpha: (print ("I think that you asked " + (question))
|
#if question.isalpha():
|
||||||
# Open the file in append & read mode ('a+')
|
# print ("I think that you asked " + (question))
|
||||||
with open("asked_questions_log.txt", "a+") as file_object:
|
# # Open the file in append & read mode ('a+')
|
||||||
# Move read cursor to the start of file.
|
# with open("asked_questions_log.txt", "a+") as file_object:
|
||||||
file_object.seek(0)
|
# # Move read cursor to the start of file.
|
||||||
# If file is not empty then append '\n'
|
# file_object.seek(0)
|
||||||
data = file_object.read(100)
|
# # If file is not empty then append '\n'
|
||||||
if len(data) > 0 :
|
# data = file_object.read(100)
|
||||||
file_object.write("\n")
|
# if len(data) > 0 :
|
||||||
# Append text at the end of file
|
# file_object.write("\n")
|
||||||
file_object.write(question))
|
# # Append text at the end of file
|
||||||
|
# file_object.write(question)
|
||||||
|
|
||||||
|
if(question and question.strip()):
|
||||||
|
print ("I think that you asked " + (question))
|
||||||
|
# Open the file in append & read mode ('a+')
|
||||||
|
with open("asked_questions_log.txt", "a+") as file_object:
|
||||||
|
# Move read cursor to the start of file.
|
||||||
|
file_object.seek(0)
|
||||||
|
# If file is not empty then append '\n'
|
||||||
|
data = file_object.read(100)
|
||||||
|
if len(data) > 0 :
|
||||||
|
file_object.write("\n")
|
||||||
|
# Append text at the end of file
|
||||||
|
file_object.write(question)
|
||||||
|
else :
|
||||||
|
print ("Goodbye!")
|
||||||
|
sys.exit
|
||||||
|
|
||||||
#else:
|
#else:
|
||||||
# sys.exit()
|
# sys.exit()
|
||||||
|
|
@ -29,8 +45,8 @@ if question.isalpha: (print ("I think that you asked " + (question))
|
||||||
#jaccard_similarity(list1, list2)
|
#jaccard_similarity(list1, list2)
|
||||||
|
|
||||||
|
|
||||||
with open('faq.json', 'r') as f:
|
#with open('faq.json', 'r') as f:
|
||||||
questionBank = json.load(f)
|
# questionBank = json.load(f)
|
||||||
|
|
||||||
# Output json file for testing
|
# Output json file for testing
|
||||||
print(questionBank)
|
#print(questionBank)
|
||||||
Loading…
Reference in a new issue