基於Python Flask所搭建的智慧音箱Server
- jieba==0.39
- Flask==0.12.2
- gensim==3.1.0
- pymongo==3.6.0
- whoosh==2.7.4
-
從良醫網及健康百科收集語料 (約有16500篇文章),使用 Word2Vec 訓練模型
-
將不同類型的字詞分為不同 domain,並將 domain 內 concept 的字詞,與使用者斷詞後的字詞丟入模型內判斷相似度。
若字詞沒有在模型內,會產生 KeyError,則會進到我們額外定義好的 domain (直接比對字詞)
-
根據不同字詞的domain,去資料庫找尋合適的回覆語句
目前有定義 8 種 domain
- chronic:慢性病
- cold:感冒
- custom:個人化
- city:城市
- steet:街道
- location:地點
- distance:距離
- yesno:是非
Run Server
cd AIBox-Server
python run.pyRun Client
# client.py
import requests
import json
while True:
dic = json.loads(message.text)
flag = dic['flag']
sentence = input('請公威:')
response_info = {'flag': flag, 'response': sentence}
message = requests.post("http://127.0.0.1:5000/api/chatbot", json=response_info)
print(message.text)cd AIBox-Client
python client.py
