本文整理汇总了Python中alex.components.slu.da.DialogueActConfusionNetwork.remove方法的典型用法代码示例。如果您正苦于以下问题:Python DialogueActConfusionNetwork.remove方法的具体用法?Python DialogueActConfusionNetwork.remove怎么用?Python DialogueActConfusionNetwork.remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类alex.components.slu.da.DialogueActConfusionNetwork
的用法示例。
在下文中一共展示了DialogueActConfusionNetwork.remove方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _infer_last_talked_about_slots
# 需要导入模块: from alex.components.slu.da import DialogueActConfusionNetwork [as 别名]
# 或者: from alex.components.slu.da.DialogueActConfusionNetwork import remove [as 别名]
def _infer_last_talked_about_slots(self, user_da, system_da):
"""This adds dialogue act items to support inference of the last slots the user talked about."""
old_user_da = deepcopy(user_da)
new_user_da = DialogueActConfusionNetwork()
colliding_slots = {}
done_slots = set()
for prob, user_dai in user_da:
new_user_dais = []
lta_tsvs = self.ontology.last_talked_about(user_dai.dat, user_dai.name, user_dai.value)
for name, value in lta_tsvs:
new_user_dais.append(DialogueActItem("inform", name, value))
if name in done_slots:
if not name in colliding_slots:
colliding_slots[name] = set()
colliding_slots[name].add(value)
else:
done_slots.add(name)
if new_user_dais:
for nudai in new_user_dais:
if not nudai in new_user_da:
new_user_da.add(prob, nudai)
# In case of collisions, prefer the current last talked about values if it is one of the colliding values.
# If there is a collision and the current last talked about value is not among the colliding values, do not
# consider the colliding DA's at all.
invalid_das = set()
for prob, da in set(new_user_da):
if da.name in colliding_slots and self[da.name].mpv() in colliding_slots[da.name]:
if not da.value == self[da.name].mpv():
invalid_das.add(da)
elif da.name in colliding_slots:
invalid_das.add(da)
for invalid_da in invalid_das:
new_user_da.remove(invalid_da)
old_user_da.merge(new_user_da, combine='max')
return old_user_da