You've already forked ui-cviko1
Compare commits
2 Commits
5ea350c425
...
4dec993539
| Author | SHA1 | Date | |
|---|---|---|---|
|
4dec993539
|
|||
|
511b708faf
|
@@ -2,23 +2,24 @@
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 10,
|
||||
"execution_count": 4,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"< My name is AI-CHATBOT.\n",
|
||||
"< I can't do that.\n",
|
||||
"< Nope.\n",
|
||||
"< The sky is blue.\n",
|
||||
"< I go by AI-BOT\n",
|
||||
"< it's sunny today\n",
|
||||
"< we have to wait for the lake to be frozen\n",
|
||||
"< it's sunny today\n",
|
||||
"< Bye\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import random\n",
|
||||
"import re\n",
|
||||
"\n",
|
||||
"no_responses = [\n",
|
||||
" \"I can't answer that.\",\n",
|
||||
@@ -28,30 +29,24 @@
|
||||
"]\n",
|
||||
"\n",
|
||||
"responses = {\n",
|
||||
" \"What's the weather like today?\": [\n",
|
||||
" \"It's sunny!\",\n",
|
||||
" \"It seems sunny today.\",\n",
|
||||
" \"Sunny.\"\n",
|
||||
" \"name\": [\n",
|
||||
" \"my name is AI-BOT\",\n",
|
||||
" \"they call me AI-BOT\",\n",
|
||||
" \"I go by AI-BOT\"\n",
|
||||
" ],\n",
|
||||
" \"What is your name?\": [\n",
|
||||
" \"My name is AI-CHATBOT.\",\n",
|
||||
" \"It's AI-CHATBOT.\",\n",
|
||||
" \"weather\": [\n",
|
||||
" \"the weather is sunny\",\n",
|
||||
" \"it's sunny today\"\n",
|
||||
" ],\n",
|
||||
" \"What's your favorite color?\": [\n",
|
||||
" \"It's yellow.\",\n",
|
||||
" \"Yellow.\"\n",
|
||||
" ],\n",
|
||||
" \"What color is the sky?\": [\n",
|
||||
" \"The sky is blue.\",\n",
|
||||
" \"It's blue.\"\n",
|
||||
" ],\n",
|
||||
" \"Can you talk?\": [\n",
|
||||
" \"No.\",\n",
|
||||
" \"Nope.\",\n",
|
||||
" \"I can't do that.\"\n",
|
||||
" \"hockey\": [\n",
|
||||
" \"good winter time!\",\n",
|
||||
" \"we have to wait for the lake to be frozen\"\n",
|
||||
" ]\n",
|
||||
"}\n",
|
||||
"\n",
|
||||
"communication_stack = []\n",
|
||||
"intent_database = [key for key in responses.keys()]\n",
|
||||
"\n",
|
||||
"while True:\n",
|
||||
" message = input(\"> \")\n",
|
||||
"\n",
|
||||
@@ -59,8 +54,15 @@
|
||||
" print(\"< Bye\")\n",
|
||||
" break\n",
|
||||
" \n",
|
||||
" if message in responses.keys():\n",
|
||||
" print(\"<\", random.choice(responses[message]))\n",
|
||||
" message = re.sub(\"[ ,.?!:;]\", \" \", message)\n",
|
||||
" words = message.split()\n",
|
||||
"\n",
|
||||
" for word in words:\n",
|
||||
" if word in intent_database:\n",
|
||||
" communication_stack.append(word)\n",
|
||||
" \n",
|
||||
" if communication_stack:\n",
|
||||
" print(\"<\", random.choice(responses[communication_stack.pop()]))\n",
|
||||
" else:\n",
|
||||
" print(\"<\", random.choice(no_responses))"
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user