一、各个模块输入输出伪代码
整体流程:
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 <-- "对不起,不明白您的意思"