用实体列表填充插槽 |拉萨
Filling slot with a list of entities | Rasa
我试图从用户那里获取 phone 数字,但有时语音识别 returns 字符而不是数字,例如:
"my contact is zero three one one seven two one one."
因此,为了获得这些值,我使用具有数字维度的小鸭来检测这一点。它将所有数字检测为实体,所以现在我需要的是从 wntities 中获取所有数字值并将它们连接起来以获得完整数字并将其值放入插槽中。我试过使用 self.from_entity('number')
但它只有 returns 列表中的最后一个值。
有什么方法可以解决这个问题,或者我应该考虑任何解决方法。
您可以在验证函数中执行此操作,方法是检查为特定用户消息提取的 number
实体的所有值,并将它们连接起来。所以你仍然会填充你的插槽 from_entity
但在你的验证函数中你实际上会去获取所有值。 dates/times的句子有一个类似的例子,你需要按照函数定义来查看详细信息:https://github.com/RasaHQ/financial-demo/blob/d6f54f77b081b2136c892fce0fc2e999a2589616/actions/actions.py#L267
我的rasa版本号是1.9.6。我用 regular expression 提取手机号码。我们可以根据要求重新格式化regex:mobileno。
## intent:inform
- [97504*****](mobileno)
- [87459*****](mobileno)
## regex:mobileno
- [6789]{1}\d{4}?[\d]{5}$
rasa shell nlu 输出
Next Message:
9999999999
{
"intent": {
"name": "inform",
"confidence": 0.9978736042976379
},
"entities": [
{
"entity": "mobileno",
"start": 0,
"end": 10,
"extractor": "DIETClassifier",
"value": "999999999"
}
],
...,
...,
"text": "9999999999"
}
我试图从用户那里获取 phone 数字,但有时语音识别 returns 字符而不是数字,例如:
"my contact is zero three one one seven two one one."
因此,为了获得这些值,我使用具有数字维度的小鸭来检测这一点。它将所有数字检测为实体,所以现在我需要的是从 wntities 中获取所有数字值并将它们连接起来以获得完整数字并将其值放入插槽中。我试过使用 self.from_entity('number')
但它只有 returns 列表中的最后一个值。
有什么方法可以解决这个问题,或者我应该考虑任何解决方法。
您可以在验证函数中执行此操作,方法是检查为特定用户消息提取的 number
实体的所有值,并将它们连接起来。所以你仍然会填充你的插槽 from_entity
但在你的验证函数中你实际上会去获取所有值。 dates/times的句子有一个类似的例子,你需要按照函数定义来查看详细信息:https://github.com/RasaHQ/financial-demo/blob/d6f54f77b081b2136c892fce0fc2e999a2589616/actions/actions.py#L267
我的rasa版本号是1.9.6。我用 regular expression 提取手机号码。我们可以根据要求重新格式化regex:mobileno。
## intent:inform
- [97504*****](mobileno)
- [87459*****](mobileno)
## regex:mobileno
- [6789]{1}\d{4}?[\d]{5}$
rasa shell nlu 输出
Next Message:
9999999999
{
"intent": {
"name": "inform",
"confidence": 0.9978736042976379
},
"entities": [
{
"entity": "mobileno",
"start": 0,
"end": 10,
"extractor": "DIETClassifier",
"value": "999999999"
}
],
...,
...,
"text": "9999999999"
}