diff --git a/asked_questions_log.txt b/asked_questions_log.txt index d033c45..0f8b88e 100644 --- a/asked_questions_log.txt +++ b/asked_questions_log.txt @@ -1,4 +1,10 @@ hi /nboo /n test -test2 \ No newline at end of file +test2 +test123 +Testing exit code + + + + diff --git a/main.py b/main.py index 1539a87..038b2a0 100644 --- a/main.py +++ b/main.py @@ -1,14 +1,10 @@ import json +import sys print("Hello, I am a question answering bot.\n") question = str(input("Please enter a question, and press the ENTER key:\n")) -print ("I think that you asked " + (question)) - -#Record question to asked question log file -#with open('asked_questions_log.txt', 'a') as f: -# f.write('{} {}'.format(question,"/n")) - -# Open the file in append & read mode ('a+') -with open("asked_questions_log.txt", "a+") as file_object: +if question.isalpha: (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' @@ -16,7 +12,13 @@ with open("asked_questions_log.txt", "a+") as file_object: if len(data) > 0 : file_object.write("\n") # Append text at the end of file - file_object.write(question) + file_object.write(question)) + + +#else: +# sys.exit() + + #def jaccard_similarity(list1, list2): # s1 = set(list1) @@ -30,5 +32,5 @@ with open("asked_questions_log.txt", "a+") as file_object: with open('faq.json', 'r') as f: questionBank = json.load(f) -# Output: {'name': 'Bob', 'languages': ['English', 'French']} +# Output json file for testing print(questionBank) \ No newline at end of file