question logging working

This commit is contained in:
David Lawler 2022-03-01 09:18:27 +10:00
parent f5c7bbab00
commit 181859f007
2 changed files with 22 additions and 3 deletions

4
asked_questions_log.txt Normal file
View file

@ -0,0 +1,4 @@
hi /nboo /n
test
test2

21
main.py
View file

@ -1,7 +1,22 @@
import json import json
#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"))
#print ("I think that you asked " + (Question)) 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:
# 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)
#def jaccard_similarity(list1, list2): #def jaccard_similarity(list1, list2):
# s1 = set(list1) # s1 = set(list1)