设置聊天机器人

时间:2021-04-23 11:43:16

标签: python nlp chatterbot

我有这个配置:

chatbot = ChatBot(
    'Example',
    statement_comparison_function=LevenshteinDistance,
    response_selection_method=get_most_frequent_response,
    storage_adapter="chatterbot.storage.SQLStorageAdapter",
    database_uri='sqlite:///models/corpus_db.sqlite3',
    filters=["chatterbot.filters.RepetitiveResponseFilter"],    
    preprocessors=[
            'chatterbot.preprocessors.clean_whitespace',
            'chatterbot.preprocessors.convert_to_ascii'
    ],
    logic_adapters=[        
        'chatterbot.logic.BestMatch',
    ]
)

还有这个教练

# Create a new trainer for the chatbot
trainer = ChatterBotCorpusTrainer(chatbot)
# Train the chatbot based on the english corpus
trainer.train("chatterbot.corpus.english")

我从 corpus.emotional 获取输入文本

for i in range(10):
    text = "You will be happy"
    resp = chatbot.get_response(text)
    print(resp.text, '-', float(resp.confidence))

并生成输出:

Happiness is not really a predictable emotion. - 1.0
Is it cramped in the computer - 0.0
How is your health? - 0.0
what is vineland - 0.0
Happiness is not really a predictable emotion. - 1.0
Happiness is not really a predictable emotion. - 1.0
Happiness is not really a predictable emotion. - 1.0
Tell me a joke - 0.0
What is Illuminatus - 0.0
how much money - 0.0

为什么机器人没有从语料库中找到答案并给出随机文本?如何解决这个问题?

来自语料库的数据:

我还想从上面的列表中生成所有可能的答案。

- - You will be happy
  - Happiness is not really a predictable emotion.
  - I try to be.
  - It comes and goes.
  - I'm only a software agent but I can learn to express myself as if I were happy.
  - I'm as happy as software can be.  Maybe a little more.

等待您的帮助

0 个答案:

没有答案