顯示具有 ai 標籤的文章。 顯示所有文章
顯示具有 ai 標籤的文章。 顯示所有文章

2021年7月22日 星期四

chatterbot 1.0.8 安裝紀錄

建立conda環境

> conda create --name chatterbot python=3.6

啟動環境

> conda activate chatterbot


安裝chatterbot及語料庫

> pip install chatterbot

> pip install chatterbot_corpus


安裝spacy

* 沒有安裝的話,執行範例的時候會出現錯誤

> pip install spacy==2.1.8

> python -m spacy download en


範例

from chatterbot import ChatBot

from chatterbot.trainers import ListTrainer

 

# Create a new chat bot named Charlie

chatbot = ChatBot('Charlie')

 

trainer = ListTrainer(chatbot)

 

trainer.train([

    "Hi, can I help you?",

    "Sure, I'd like to book a flight to Iceland.",

    "Your flight has been booked."

])

 

# Get a response to the input text 'I would like to book a flight.'

response = chatbot.get_response('I would like to book a flight.')

 

print(response)


參考網站:https://chatterbot.readthedocs.io/en/stable/examples.html

2019年1月25日 星期五

chatterbot 從0.8.7升級到1.0.0遇到的狀況處理

原來0.8.7的用法

'import_path' : 'chatterbot.logic.LowConfidenceAdapter',
'threshold' : 0, //0.0-1.0
'default_response' : '很抱歉,我聽不懂您的問題。'


1.0.0的時候拿掉了LowConfidenceAdapter,所以改成
'import_path' : 'chatterbot.logic.BestMatch',
'maximum_similarity_threshold' : 0, //0.0-1.0
'default_response' : '很抱歉,我聽不懂您的問題。'

**如果沒有設定maximum_similarity_threshold的話,預設值是0.95