Advertisement

chatbot

Started by April 24, 2018 05:26 PM
1 comment, last by Kylotan 6 years, 7 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

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