Hello everyone. Not sure if this is the right place, but my friend needed help with his project. If you need more details, I can tell you in the replies section, and I think you can tell based on the code. I don’t think the code has any errors, because the console didn’t say any errors.
PROBLEM: Okay so, the console goes blank, and lasts for 2 seconds (exact time). My friend is not sure what happened because the code was fine. The code is written in python and if anyone has experienced a similar or the same issue please help him.
FAQ: Questions you may ask are: Check your CPU, Run the program again, Use a debugger like pdb. We have tried this so please don’t bother asking (you can ask about the debugging though).
Additional Things: I can send you a video on what is going on in the replies section so you guys can understand clearly. [I will probably respond the next day]
Code is below:
import random
import string
import nltk
class ChatUtil(nltk.chat):
def __init__(self):
super().__init__()
print("Welcome to [TEST] chatbot!")
def start(self, handle_input):
while True:
user_input = input("You: ")
handle_input(user_input)
def handle_input(input_text):
"""Respond to the user's input."""
responses = self.process_input(input_text)
bot_response = random.choice(responses)
print(f"Bot: {bot_response}")
def process_input(input_text):
"""Determine the user's intent and respond accordingly."""
tokens = pos_tag(input_text)
request_type = None
for token in tokens:
if token[1][0].startswith("VB"):
request_type = "action"
break
else:
request_type = "information"
responses = []
if request_type == "action":
responses = [
'You can say "hello" to me!',
'I don\'t understand that request. Try saying "hello"?',
]
elif request_type == "information":
responses = ["I am LLaMA, I'm here to help!", "What would you like to know?"]
else:
responses = ["Sorry, I didn’t understand that. Try again?"]
return responses