rasa框架core源码分析

一、各个模块输入输出伪代码
整体流程:

 1. 输入:用户输入(sentence)
 2. 过程:
 3. userAct <-- NLU(sentence)
 4. dialogState <-- DST(userAct,dialogHistory)
 5. systemAct <-- DPL(dialogState)
 6. reply <-- NLG(systemAct)
 7. 输出:系统回复(reply)

NLU模块

 1. 输入:用户输入(sentence)
 2. 过程:
 3. intenRecongnizer(sentence) --> userAct.intent
 4. slotFilling(sentence,userAct.intent) --> userAct.slotArray
 5. 输出:用户动作(userAct)

DST模块


 1. 输入:用户动作(userAct)&对话历史(dialogHistory)
 2. 过程:
 3. if userAct.intent is not None:
 4. 	userAct.intent --> dialogState.intent
 5. 	userAct.slotArray --> dialogState.slotArray
 6. 	checkDefualtSlot(dialogState)
 7. else:
 8. 	getIntent(dialogHistory) --> dialogState.intent
 9. 	updateDialogState(userAct.slotArray,dialogHistory) --> dialogState.slotArray
 10.输出:对话状态(dialogState) 

DPL模块


 1. 输入:对话状态(dialogState)
 2. 过程:
 3. if dialgState.intent == "询问天气"
 4. 	if dialogState.slotArray[0] is None:
 5. 		systemAct.intent <-- "AskDate"
 6. 	elif dialogState.slotArray[1] is None:
 7. 		systemAct.intent <-- "AskLocation"
 8. 	else:
 9. 		systemAct.intent <-- "AskWeather"
 10.		systemAct.slotArray[0] <- getWeather(dialogState,slotArray)
 11.elif dialogState.intent is None:
 		systemAct.intent <-- Exception("IntentError")
 	else:
 		OtherService
 12. 输出:系统动作(systemAct) 

NLG模块


 1. 输入:系统动作(systemAct)
 2. 过程:
 3. if systemAct.intent == "AskDate":
 4. 	reply <-- "请输入时间“
 5. elif systemAct.intent == "AskLocation":
 6. 	reply <-- "请输入地点”
 7. elif systemAct.intent == "AskWeather":
 8. 	reply <-- systemAct.slotArray[0]
 9. elif systemAct.intent == "IntentError":
 10.	reply <-- "对不起,不明白您的意思" 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值