hello, I observed a problem with chatterbot.logic.TimeLogicAdapter as it is showing the time on any useless input by the user.
I think my positive and negative list is not working

you can see here it is getting triggered even on the letter 't', also not getting triggered on my positive command like 'what is time'
please help me out
``` Python
from chatterbot import ChatBot #import the chatbot
from chatterbot.trainers import ListTrainer #method to train chatbot
from chatterbot.trainers import ChatterBotCorpusTrainer
import os
time_positive=['what is the time right now','what is the current time','what is the time now','what鈥檚 the time','what time is it',
'what time is it now','do you know what time it is','could you tell me the time, please','what is the time','will you tell me the time',
'tell me the time','time please','show me the time','what is time','whats on the clock','clock','show me the clock','what is the time']
time_negative=['what are you doing','what鈥檚 up','could you','do you','what鈥檚','will you','tell me','show me','current','do','now',
'will','show','tell','me','could','what','whats','i have time','who','who is','hardtime','when is time','how is time','who is time']
bot = ChatBot(
'Example Bot',
storage_adapter='chatterbot.storage.SQLStorageAdapter',
logic_adapters=[
{
'import_path': 'chatterbot.logic.BestMatch',
'default_response': 'I am sorry, but I do not understand.',
'maximum_similarity_threshold': 0.90
},
{
'import_path': 'chatterbot.logic.TimeLogicAdapter',
'positive': 'time_positive',
'negative': 'time_negative'
}
]
)
trainer = ListTrainer(bot) #set the trainer
for _file in os.listdir('files'):
chats = open('files/' + _file, 'r').readlines()
trainer.train(chats)
filename = input ("write your name: ");
while True:
request =input("you: ")
with open(filename, "a") as f:
f.write (request + '\n');
response = bot.get_response(request)
print("bot: " + str(response))
with open(filename, "a") as f:
f.write (str(response) + '\n');
```
Yes @sohamnandi007 , the positives are working fine except you need to reduce threshold value to some where around 0.60 to see a positive response.
It has to check confidence, you could see here https://github.com/gunthercox/ChatterBot/blob/088fbe11feb221290e0b1b55232167d6c4349678/chatterbot/logic/time_adapter.py#L89
You could add a check to resolve this issue.
if response.confidence > 0:
print("bot: " + str(response))
Still not working, i can't understand the pattern sometime it works, sometimes it fails also i think it's not detecting my negative list
please provide me a solution ...
@vkosuri @quan-nh @ryancollingwood @rmdort @gunthercox

As you can see it is showing time on the letters 't' although I have put it in my negative list.
[here is my updated code]
`from chatterbot import ChatBot #import the chatbot
from chatterbot.trainers import ListTrainer #method to train chatbot
from chatterbot.trainers import ChatterBotCorpusTrainer
import os
time_positive=['what is the time right now', 'what is the current time', 'what is the time now', 'what鈥檚 the time', 'what time is it',
'what time is it now', 'do you know what time it is', 'could you tell me the time, please', 'what is the time', 'will you tell me the time',
'tell me the time', 'time please', 'time', 'show me the time', 'what is time', 'whats on the clock', 'clock', 'show me the clock', 'what is the time',
'what is on the clock']
time_negative=['what are you doing', 'what鈥檚 up', 'could you', 'do you', 'what鈥檚', 'will you', 'tell me', 'show me', 'current', 'do', 'now',
'will', 'show', 'tell', 'me', 'could', 'what', 'whats', 'i have time', 'who', 'who is', 'hardtime', 'when is time', 'how is time', 'who is time',
' ', 'when','what is','how','how is','when is','t','ti','it','tim','the','tt','t ','how is time']
bot = ChatBot(
'Example Bot',
storage_adapter='chatterbot.storage.SQLStorageAdapter',
logic_adapters=[
{
'import_path': 'chatterbot.logic.BestMatch',
'default_response': 'I am sorry, but I do not understand.',
'maximum_similarity_threshold': 0.60
},
{
'import_path': 'chatterbot.logic.TimeLogicAdapter',
'positive': 'time_positive',
'negative': 'time_negative'
}
]
)
trainer = ListTrainer(bot) #set the trainer
for _file in os.listdir('files'):
chats = open('files/' + _file, 'r').readlines()
trainer.train(chats)
filename = input ("write your name: ");
while True:
request =input("you: ")
with open(filename, "a") as f:
f.write (request + '\n');
response = bot.get_response(request)
if response.confidence > 0: #added condition
print("bot: " + str(response))
with open(filename, "a") as f:
f.write (str(response) + '\n');
# os.rename('filename.txt','hello.txt')
`
Please help me out anyone.. facing this issue..
@vkosuri @quan-nh @ryancollingwood @rmdort @gunthercox @gabru-md @gitter-badger @gsingers
Thank you @gunthercox @ryancollingwood @quan-nh @rmdort @vkosuri .. I tried out the solution. Finally, I got the answer.
I would like to request you, please include this example in the documentation for others - how to add your own list in "chatterbot.logic.TimeLogicAdapter" and call it
Thank you.
If you feel to close the issue you can
here is my final code:
from chatterbot import ChatBot #import the chatbot
from chatterbot.trainers import ListTrainer #method to train chatbot
from chatterbot.trainers import ChatterBotCorpusTrainer
import os
# import logging
# logging.basicConfig(level=logging.INFO)
#here is how to create your own time list
time_positive = ['what is the time right now','time','clock','what is the current time', 'what is the time now', 'what鈥檚 the time', 'what time is it',
'what time is it now', 'do you know what time it is', 'could you tell me the time, please', 'what is the time', 'will you tell me the time',
'tell me the time','time please', 'show me the time', 'what is time', 'whats on the clock', 'show me the clock',
'what is the time','what is on the clock','tell me time','time','clock',]
time_negative = ['what are you doing', 'what鈥檚 up','when is time','who is time' 'could you', 'do you', 'what鈥檚', 'will you', 'tell me', 'show me', 'current', 'do', 'now',
'will', 'show', 'tell','me', 'could', 'what', 'whats', 'i have time', 'who', 'who is', 'hardtime','when','what is','how',
'how is','when is','who is time','how is time','how is time','when is time']
bot = ChatBot(
'Example Bot', read_only=True,
storage_adapter='chatterbot.storage.SQLStorageAdapter',
logic_adapters=[
{
'import_path': 'chatterbot.logic.BestMatch',
'default_response': 'I am sorry, but I do not understand.',
'maximum_similarity_threshold': 0.75
},
{ #here is how to call the TimeLogicAdapter when you create your own list
'import_path': 'chatterbot.logic.TimeLogicAdapter',
'positive': time_positive,
'negative': time_negative
}
]
)
trainer = ListTrainer(bot) #set the trainer
for _file in os.listdir('files'):
chats = open('files/' + _file, 'r').readlines()
trainer.train(chats)
filename = input ("write your name: ");
while True:
request =input("you: ")
with open(filename, "a") as f:
f.write (request + '\n');
response = bot.get_response(request)
print("bot: " + str(response))
with open(filename, "a") as f:
f.write (str(response) + '\n');
Most helpful comment
Thank you @gunthercox @ryancollingwood @quan-nh @rmdort @vkosuri .. I tried out the solution. Finally, I got the answer.
I would like to request you, please include this example in the documentation for others - how to add your own list in "chatterbot.logic.TimeLogicAdapter" and call it
Thank you.
If you feel to close the issue you can
here is my final code: