本文整理汇总了Python中alex.components.slu.da.DialogueActConfusionNetwork.prune方法的典型用法代码示例。如果您正苦于以下问题:Python DialogueActConfusionNetwork.prune方法的具体用法?Python DialogueActConfusionNetwork.prune怎么用?Python DialogueActConfusionNetwork.prune使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类alex.components.slu.da.DialogueActConfusionNetwork
的用法示例。
在下文中一共展示了DialogueActConfusionNetwork.prune方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_prune
# 需要导入模块: from alex.components.slu.da import DialogueActConfusionNetwork [as 别名]
# 或者: from alex.components.slu.da.DialogueActConfusionNetwork import prune [as 别名]
def test_prune(self):
dacn = DialogueActConfusionNetwork()
dacn.add(0.05, DialogueActItem(dai='inform(food=chinese)'))
dacn.add(0.9, DialogueActItem(dai='inform(food=czech)'))
dacn.add(0.00005, DialogueActItem(dai='inform(food=russian)'))
# Russian food should be pruned.
self.assertEqual(len(dacn), 3)
dacn.prune()
self.assertEqual(len(dacn), 2)
self.assertTrue(not DialogueActItem(dai='inform(food=russian)') in dacn)
示例2: parse_nblist
# 需要导入模块: from alex.components.slu.da import DialogueActConfusionNetwork [as 别名]
# 或者: from alex.components.slu.da.DialogueActConfusionNetwork import prune [as 别名]
def parse_nblist(self, obs, *args, **kwargs):
"""
Parses an observation featuring an utterance n-best list using the
parse_1_best method.
Arguments:
obs -- a dictionary of observations
:: observation type -> observed value
where observation type is one of values for `obs_type' used in
`ft_props', and observed value is the corresponding observed
value for the input
args -- further positional arguments that should be passed to the
`parse_1_best' method call
kwargs -- further keyword arguments that should be passed to the
`parse_1_best' method call
"""
nblist = obs['utt_nbl']
if len(nblist) == 0:
return DialogueActConfusionNetwork()
obs_wo_nblist = copy.deepcopy(obs)
del obs_wo_nblist['utt_nbl']
dacn_list = []
for prob, utt in nblist:
if "_other_" == utt:
dacn = DialogueActConfusionNetwork()
dacn.add(1.0, DialogueActItem("other"))
elif "_silence_" == utt:
dacn = DialogueActConfusionNetwork()
dacn.add(1.0, DialogueActItem("silence"))
else:
obs_wo_nblist['utt'] = utt
dacn = self.parse_1_best(obs_wo_nblist, *args, **kwargs)
dacn_list.append((prob, dacn))
dacn = merge_slu_confnets(dacn_list)
dacn.prune()
dacn.sort()
return dacn