Pythonを使用したMLチャットボット。
チャットボットは、人間のようにユーザーと対話するアプリケーションです。チャットボットは通常、企業が顧客から毎日受け取る最も一般的な質問を解決するために使用されます。この記事では、Python を使用して基本的なチャットボットを作成するプロセスを説明します。同じことを即興で作成して、より複雑なチャットボットを作成できます。
チャットボットとは何ですか?
チャットボットは人間の会話を模倣する AI アプリケーションです。企業が毎日顧客から受け取る最も一般的な問題を解決するために広く使用されています。したがって、どの企業向けにチャットボットを作成する場合でも、その企業が何を扱っているのか、顧客が毎日どのような問題に直面しているのかを把握する必要があります。以下のセクションでは、Python を使用してチャットボットを作成する方法を説明します。
Pythonを使ったAIチャットボット
チャットボットとは何なのか、そしてなぜ多くの企業が顧客の最も一般的な問題を解決するためにチャットボットを使用しているのかが理解できたと思います。では、Python を使用してチャットボットを作成する方法を見てみましょう。ここでは、自然言語処理のタスクに最適な Python ライブラリの 1 つであるNLTK ライブラリを Python で使用します。
次に、チャットボットのクエリとその応答のリストを作成します。
#Chatbot and my_reflections are list of patterns and responses.
my_reflections= {
"you": "I",
"your": "my",
"you're": "I'm",
"I": "you",
"my": "your",
"I'm": "you're"
}
chatbot = [
[
r"(.*)my name is (.*)",
["Hello %2, How are you today ?",]
],
[
r"(.*)help(.*) ",
["I can help you ",]
],
[
r"(.*) your name ?",
["My name is AI BOT, but you can just call me robot and I'm a chatbot .",]
],
[
r"how are you (.*) ?",
["I'm doing very well", "i am great !"]
],
[
r"sorry (.*)",
["Its alright","Its OK, never mind that",]
],
[
r"i'm (.*) (good|well|okay|ok)",
["Nice to hear that","Alright, great !",]
],
[
r"(hi|hey|hello|hola|holla)(.*)",
["Hello", "Hey there",]
],
[
r"what (.*) want ?",
["Make me an offer I can't refuse",]
],
[
r"(.*)created(.*)",
["Akhil Makol created me using Python's NLTK library ","top secret ;)",]
],
[
r"(.*) (location|city) ?",
['Haryana, India',]
],
[
r"(.*)raining in (.*)",
["No rain in the past 4 days here in %2","In %2 there is a 50% chance of rain",]
],
[
r"how (.*) health (.*)",
["Health is very important, but I am a computer, so I don't need to worry about my health ",]
],
[
r"(.*)(sports|game|sport)(.*)",
["I'm a very big fan of Cricket",]
],
[
r"who (.*) (Cricketer|Batsman)?",
["Virat Kohli"]
],
[
r"quit",
["Bye for now. See you soon :) ","It was nice talking to you. See you soon :)"]
],
[
r"(.*)",
['That is nice to hear']
],
]
#default message at the start of chat
print("Hi, I'm AI BOT and I like to chat\nPlease type lowercase English language to start a conversation. Type quit to leave ")
#Create Chat Bot
chat = Chat(chatbot, my_reflections)
#Start conversation
chat.converse()
まとめ
チャットボットは、特に企業が何らかの種類のサービスを提供している場合、あらゆる企業にとって非常に便利なアプリケーションです。顧客からの最も一般的な質問を解決することで、組織を支援します。Python を使用してチャットボットを作成する方法に関するこの記事が気に入っていただければ幸いです。以下のコメントセクションでお気軽に貴重なご質問をお寄せください。
GitHub:メインの ML-Chatbot-using-Python/chatbot.py · akhilmakol/ML-Chatbot-using-Python (github.com)

![とにかく、リンクリストとは何ですか?[パート1]](https://post.nghiatu.com/assets/images/m/max/724/1*Xokk6XOjWyIGCBujkJsCzQ.jpeg)



































