My First ChatBot using NLTK v3.5
Nov 3, 2020
Natural Language Toolkit (NLTK)
- Is a Python package for natural language processing NLP
- Is a leading platform for building Python programs to work with human language data.
from nltk.chat.util import Chat, reflections
pairs = [
[ r”hey”, [“Hey there”]],
[ r”my name is (.*)”, [“Hello %1, How are you today?”]],
[ r”what is your name?”, [“My name is Chatty”]],
[ r”what is your age?”, [“I’m a computer program, you are asking me this”]],
[ r”what your best sport or game?”, [“I’m a very big fan of football “]],
[ r”quit”, [“It was nice talking to you. See you soon :)”]],]
def chatty():
print(“Hi, I’m Chatty We can chat alot if you have any Question”)
chat = Chat(pairs, reflections)
chat.converse()
if __name__ == “__main__”:
chatty()