Я не получаю никакого ответа от обученной модели в болтовне - PullRequest
0 голосов
/ 06 мая 2019

После обучения модели с использованием функции ответа, полученной ниже error.it не дает мне никакого ответа, скорее выдает ошибку типа

"runfile('C:/Users/Chandrapal Panwar/Desktop/python/python_coding/chat2.py', wdir='C:/Users/Chandrapal Panwar/Desktop/python/python_coding')
wow
Traceback (most recent call last):
  File "C:\Python\Python36\lib\site- 
 packages\IPython\core\interactiveshell.py", line 2862, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-3-1c8a35a0db59>", line 1, in <module>
    wow
NameError: name 'diabetes' is not defined"

Я храню данные в YAML, как показано ниже:

categories:
  -   Clinical trials
      conversations:
  - - what is the definition of a diabetes.?
    - "a disease in which the body’s ability to produce or respond to the hormone insulin is impaired, resulting in abnormal metabolism of carbohydrates and elevated levels of glucose in the blood."  

дрессировочный болтун работает нормально, но при получении ответа выдает ошибку:

from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer
from chatterbot.trainers import ChatterBotCorpusTrainer
import os


def setup():
    chatbot = ChatBot('Bot',storage_adapter='chatterbot.storage.SQLStorageAdapter',trainer='chatterbot.trainers.ListTrainer')
    mainDir = 'C:\\chatterbot\\data\\'
    for _file in os.listdir( mainDir ):
        chats = open( mainDir + _file, 'r' ).readlines()
        chatbot.train( chats )
        print("Training completed")

setup()
def get_response(usrText):
    bot = ChatBot('Norman',
                  storage_adapter='chatterbot.storage.SQLStorageAdapter',
                  input_adapter='chatterbot.input.TerminalAdapter',
                  output_adapter='chatterbot.output.TerminalAdapter',
    logic_adapters=[
        {
            'import_path': 'my_logic_adapter.MyLogicAdapter',
            "statement_comparison_function": "chatterbot.comparisons.JaccardSimilarity",
            "response_selection_method": "chatterbot.response_selection.get_random_response",
            'threshold': 0.65,
            'default_response': 'I am sorry, but I do not understand.'

        }
    ],
              filters=["chatterbot.filters.RepetitiveResponseFilter"],
                  preprocessors=[
                      'chatterbot.preprocessors.clean_whitespace',
                      'chatterbot.preprocessors.unescape_html',
                      'chatterbot.preprocessors.convert_to_ascii'
                  ],
                  database='./database.sqlite3',
    trainer='chatterbot.trainers.ListTrainer')
    bot.set_trainer(ListTrainer)
    while True:
        if usrText.strip()!= 'Bye':
            result = bot.get_response(usrText)
            reply = str(result)
            return(reply)
        if usrText.strip() == 'Bye':
            return('Bye')
            break
```

What is the definition of a diabetes?
a disease in which the body’s ability to produce or respond to the hormone insulin is impaired, resulting in abnormal metabolism of carbohydrates and elevated levels of glucose in the blood.
...