top of page

Python - chatbot - nltk


Chatbot characteristics are small data set, very simple analytics and primitive communication function. The first chatbots were developed in 1966 and today they handle around 80% of customer-brand communication. Chatbots have implemented various algorithms: mathematical, best match, training, evaluation, gesture recognition, voice recognition.


Suitable python packages for chatbots are Chatterbot (easy), nltk (easy to use), spaCy (NLP basics), TextBlob (simple), DeepPavlov (more sophisticated, built on Keras and TensorFlow), PyNLPI (basic tasks). pip install nltk


pip install spacy



import nltk


from nltk.chat.util import Chat, reflections


print(Chat)


reflections


set_pairs = [

[

r"my name is (.*)",

["Hello %1, How are you doing today ?",]

],

[

r"hi|hey|hello",

["Hello", "Hey there",]

],

[

r"what is your name?",

["You can call me Sarka ",]

],

[

r"how are you ?",

["I am fine, thank you! How can i help you?",]

],

[

r"I am fine, thank you",

["great to hear that, how can i help you?",]

],

[

r"how can i help you? ",

["i am looking for online guides and courses to learn data science, can you suggest?", "i am looking for python platforms",]

],

[

r"i'm (.*) doing good",

["That's great to hear","How can i help you?:)",]

],

[

r"i am looking for online python chatbot, can you suggest?",

["This is a basic option to create Python nltk chatbot.",]

],

[

r"thanks for the suggestion. do you have more tips?",

["Yes, try another Blog posts as well or revise the links below.",]

],

[

r"(.*) thank you so much, that was helpful",

["No problem", "No problem, you're welcome",]

],

[

r"quit",

["Bye and thank you.","Thank you for chat."]

],

]



def chatbot():

print("Hi, I'm the chatbot you built”)


chatbot()


chat = Chat(set_pairs, reflections)


print(chat)


chat.converse()

if __name__ == "__main__":

chatbot()



>hello

Hello

>i am looking for online python chatbot

None

>i am looking for online python chatbot, can you suggest?

This is a basic option to create Python nltk chatbot.









Recent Posts

See All

Comments


bottom of page