我正在尝试制作一个聊天机器人,为此我需要执行两个主要任务:意图分类和实体识别,但我在意图分类方面遇到了困难。基本上,我正在为电子商务网站开发一个聊天机器人,它有一个非常具体的用例,就是与客户就产品价格进行协商。为了让事情简单明了,我只考虑了5个意图:
- 询问价格
- 还价
- 谈判
- 成功
- 购买产品
from textblob.classifiers import NaiveBayesClassifier
import joblib # This is used to save the trained classifier in pickle format
training_data = [
('i want to buy a jeans pent', 'Buy_a_product'),
('i want to purchase a pair of shoes', 'Buy_a_product'),
('are you selling laptops', 'Buy_a_product'),
('i need an apple jam', 'Buy_a_product'),
('can you please tell me the price of this product', 'Buy_a_product'),
('please give me some discount.', 'negotition'),
("i cannot afford such price", 'negotition'),
("could you negotiate", "negotition"),
("i agree on your offer", "success"),
("yes i accepcted your offer", "success"),
("offer accepted", "success"),
("agreed", "success"),
("what is the price of this watch", "ask_for_price"),
("How much it's cost", "ask_for_price"),
("i will only give you 3000 for this product", "counter_offer"),
("Its too costly i can only pay 1500 for it", "counter_offer"),
]
clf = NaiveBayesClassifier(training_data)
joblib.dump(clf, 'intentClassifier.pkl')