本文整理汇总了Python中alex.components.slu.da.DialogueActConfusionNetwork.get_da_nblist方法的典型用法代码示例。如果您正苦于以下问题:Python DialogueActConfusionNetwork.get_da_nblist方法的具体用法?Python DialogueActConfusionNetwork.get_da_nblist怎么用?Python DialogueActConfusionNetwork.get_da_nblist使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类alex.components.slu.da.DialogueActConfusionNetwork
的用法示例。
在下文中一共展示了DialogueActConfusionNetwork.get_da_nblist方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_da_nblist
# 需要导入模块: from alex.components.slu.da import DialogueActConfusionNetwork [as 别名]
# 或者: from alex.components.slu.da.DialogueActConfusionNetwork import get_da_nblist [as 别名]
def test_get_da_nblist(self):
# Simple case with one good hypothesis.
dacn = DialogueActConfusionNetwork()
dacn.add(0.05, DialogueActItem(dai='inform(food=chinese)'))
dacn.add(0.9, DialogueActItem(dai='inform(food=czech)'))
dacn.add(0.05, DialogueActItem(dai='inform(food=russian)'))
nblist = dacn.get_da_nblist()
best_da = nblist.get_best_da()
expected_da = DialogueAct(da_str='inform(food=czech)')
self.assertEqual(best_da, expected_da)
# More good hypotheses
dacn = DialogueActConfusionNetwork()
dacn.add(0.05, DialogueActItem(dai='inform(food=chinese)'))
dacn.add(0.9, DialogueActItem(dai='inform(food=czech)'))
dacn.add(0.9, DialogueActItem(dai='inform(food=russian)'))
nblist = dacn.get_da_nblist()
best_da = nblist.get_best_da()
expected_da = DialogueAct(da_str='inform(food=czech)&inform(food=russian)')
self.assertEqual(best_da, expected_da)
示例2: test_session_logger
# 需要导入模块: from alex.components.slu.da import DialogueActConfusionNetwork [as 别名]
# 或者: from alex.components.slu.da.DialogueActConfusionNetwork import get_da_nblist [as 别名]
def test_session_logger(self):
cfg = Config.load_configs(config=CONFIG_DICT, use_default=False)
sl = SessionLogger()
# test 3 calls at once
for i in range(3):
sess_dir = "./%d" % i
if not os.path.isdir(sess_dir):
os.mkdir(sess_dir)
sl.session_start(sess_dir)
sl.config('config = ' + unicode(cfg))
sl.header(cfg['Logging']["system_name"], cfg['Logging']["version"])
sl.input_source("voip")
sl.dialogue_rec_start(None, "both_complete_dialogue.wav")
sl.dialogue_rec_start("system", "system_complete_dialogue.wav")
sl.dialogue_rec_start("user", "user_complete_dialogue.wav")
sl.dialogue_rec_end("both_complete_dialogue.wav")
sl.dialogue_rec_end("system_complete_dialogue.wav")
sl.dialogue_rec_end("user_complete_dialogue.wav")
sl.turn("system")
sl.dialogue_act("system", "hello()")
sl.text("system", "Hello.")
sl.rec_start("system", "system1.wav")
sl.rec_end("system1.wav")
sl.turn("user")
sl.rec_start("user", "user1.wav")
sl.rec_end("user1.wav")
A1, A2, A3 = 0.90, 0.05, 0.05
B1, B2, B3 = 0.70, 0.20, 0.10
C1, C2, C3 = 0.80, 0.10, 0.10
asr_confnet = UtteranceConfusionNetwork()
asr_confnet.add([[A1, "want"], [A2, "has"], [A3, 'ehm']])
asr_confnet.add([[B1, "Chinese"], [B2, "English"], [B3, 'cheap']])
asr_confnet.add([[C1, "restaurant"], [C2, "pub"], [C3, 'hotel']])
asr_confnet.merge()
asr_confnet.normalise()
asr_confnet.sort()
asr_nblist = asr_confnet.get_utterance_nblist()
sl.asr("user", "user1.wav", asr_nblist, asr_confnet)
slu_confnet = DialogueActConfusionNetwork()
slu_confnet.add(0.7, DialogueActItem('hello'))
slu_confnet.add(0.6, DialogueActItem('thankyou'))
slu_confnet.add(0.4, DialogueActItem('restart'))
slu_confnet.add(0.1, DialogueActItem('bye'))
slu_confnet.merge()
slu_confnet.normalise()
slu_confnet.sort()
slu_nblist = slu_confnet.get_da_nblist()
sl.slu("user", "user1.wav", slu_nblist, slu_confnet)
sl.turn("system")
sl.dialogue_act("system", "thankyou()")
sl.text("system", "Thank you.", cost = 1.0)
sl.rec_start("system", "system2.wav")
sl.rec_end("system2.wav")
sl.barge_in("system", tts_time = True)
sl.turn("user")
sl.rec_start("user", "user2.wav")
sl.rec_end("user2.wav")
sl.hangup("user")