🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

chatbot

Started by
1 comment, last by Kylotan 6 years, 2 months ago

 

Please help in completing the code. I am unable to use defined function

 

import sys
import nltk
import random
from nltk.tokenize import word_tokenize,sent_tokenize
GREETING_KEYWORDS = ("hello", "hi", "greetings", "sup", "what's up",)

GREETING_RESPONSES = ["'sup bro", "hey", "*nods*", "hey you get my snap?"]

User_input = input ("User said:")
type (User_input)

def check_for_greeting(sentence):
    """If any of the words in the user's input was a greeting, return a greeting response"""
    words = word_tokenize (sentence)
    if words in GREETING_KEYWORDS:
     print(random.choice(GREETING_RESPONSES))
    return; 
check_for_greeting(sentence = User_input )

gourav
Advertisement

You must post the errors that you receive if you want us to help you with them.

This topic is closed to new replies.

Advertisement