You've already forked ui-cviko1
pamätanie kľúčových slov
This commit is contained in:
@@ -2,19 +2,17 @@
|
|||||||
"cells": [
|
"cells": [
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": 4,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
{
|
{
|
||||||
"name": "stdout",
|
"name": "stdout",
|
||||||
"output_type": "stream",
|
"output_type": "stream",
|
||||||
"text": [
|
"text": [
|
||||||
"< I can't understand you.\n",
|
"< I go by AI-BOT\n",
|
||||||
"< the weather is sunny\n",
|
"< it's sunny today\n",
|
||||||
"< I don't know, sorry.\n",
|
"< we have to wait for the lake to be frozen\n",
|
||||||
"< I can't answer that.\n",
|
"< it's sunny today\n",
|
||||||
"< I don't know, sorry.\n",
|
|
||||||
"< good winter time!\n",
|
|
||||||
"< Bye\n"
|
"< Bye\n"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -46,6 +44,7 @@
|
|||||||
" ]\n",
|
" ]\n",
|
||||||
"}\n",
|
"}\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
"communication_stack = []\n",
|
||||||
"intent_database = [key for key in responses.keys()]\n",
|
"intent_database = [key for key in responses.keys()]\n",
|
||||||
"\n",
|
"\n",
|
||||||
"while True:\n",
|
"while True:\n",
|
||||||
@@ -58,9 +57,12 @@
|
|||||||
" message = re.sub(\"[ ,.?!:;]\", \" \", message)\n",
|
" message = re.sub(\"[ ,.?!:;]\", \" \", message)\n",
|
||||||
" words = message.split()\n",
|
" words = message.split()\n",
|
||||||
"\n",
|
"\n",
|
||||||
" intent_word = next((word for word in words if word in intent_database), None)\n",
|
" for word in words:\n",
|
||||||
" if intent_word != None:\n",
|
" if word in intent_database:\n",
|
||||||
" print(\"<\", random.choice(responses[intent_word]))\n",
|
" communication_stack.append(word)\n",
|
||||||
|
" \n",
|
||||||
|
" if communication_stack:\n",
|
||||||
|
" print(\"<\", random.choice(responses[communication_stack.pop()]))\n",
|
||||||
" else:\n",
|
" else:\n",
|
||||||
" print(\"<\", random.choice(no_responses))"
|
" print(\"<\", random.choice(no_responses))"
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user