所以你有两个问题,
ID提取和
意图检测。
ID提取
如果您的ID遵循规律,并且看起来肯定不像英语,那么您可以使用正则表达式捕获它们-如果可能,那非常好,因为这很容易做到。如果您有一个固定的产品ID列表,请检查其中是否有任何输入。如果以上两种方法都不起作用,则必须变得更加复杂。
您能让用户记住一些语法吗?如果您可以请求他们使用类似于id:X26TH
的前缀编写内容,那么您的工作将变得更加容易。您可能会发现Plan9中的plumber的工作方式很有启发性。
如果您需要处理用户提交的任何内容,则应考虑使用序列标注器或命名实体识别(NER)系统获取ID。 CRF可能非常适合此任务;这里是一个很好的技术介绍,纽约时报也成功地使用了其中的一个。除了需要更复杂的设置外,这种方法的缺点是需要训练数据,但确实没有避免的方法。
意图检测
通常将其建模为文本分类问题。您可以在此处找到如何做到这一点的概述。以下是文章中的一些培训示例:
training_data.append({"class":"greeting", "sentence":"how are you?"})
training_data.append({"class":"greeting", "sentence":"how is your day?"})
training_data.append({"class":"greeting", "sentence":"good day"})
training_data.append({"class":"greeting", "sentence":"how is it going today?"})
training_data.append({"class":"goodbye", "sentence":"have a nice day"})
training_data.append({"class":"goodbye", "sentence":"see you later"})
training_data.append({"class":"goodbye", "sentence":"have a nice day"})
training_data.append({"class":"goodbye", "sentence":"talk to you soon"})
training_data.append({"class":"sandwich", "sentence":"make me a sandwich"})
training_data.append({"class":"sandwich", "sentence":"can you make a sandwich?"})
training_data.append({"class":"sandwich", "sentence":"having a sandwich today?"})
training_data.append({"class":"sandwich", "sentence":"what's for lunch?"})