diff --git a/src/dme.ts b/src/dme.ts index 21a2c6b..6e7f11e 100644 --- a/src/dme.ts +++ b/src/dme.ts @@ -75,6 +75,7 @@ export const dme = setup({ always: [ isuTransition("SelectMove", "select_respond"), isuTransition("SelectMove", "select_from_plan"), + isuTransition("SelectMove", "selectIcmSemNeg"), { target: "SelectMove" }, // TODO check it -- needed for greeting ], }, diff --git a/src/nlug.ts b/src/nlug.ts index dfd3741..5fd62c3 100644 --- a/src/nlug.ts +++ b/src/nlug.ts @@ -11,10 +11,34 @@ const nluMapping: NLUMapping = { type: "ask", content: WHQ("booking_room"), }], + "which day is the lecture": [{ + type: "ask", + content: WHQ("booking_day"), + }], + "what's your favorite food?": [{ type: "ask", content: WHQ("favorite_food"), }], + +/* "I am sorry, I don't understand you.": [{ + type: "FailedNlu", + content: null, + }], */ + + monday: [{ + type: "answer", + content: "monday", + }], + + thursday: [{ + type: "answer", + content: "thursday", + }], + + + + pizza: [{ type: "answer", content: "pizza", @@ -27,10 +51,25 @@ const nluMapping: NLUMapping = { type: "answer", content: "LT2319", }], + + + }; + + const nlgMapping: NLGMapping = [ - [{ type: "ask", content: WHQ("booking_course") }, "Which course?"], + [{type: "ask", content: WHQ("booking_course") }, "Which course?"], + [{ type: "ask", content: WHQ("booking_day") }, "Which day is the lecture?"], + [{type: "greet", content: null }, "Hello! You can ask me anything!"], + [{type : "FailedNlu", content: null}, "I am sorry, I don't understand you."], + + /* [{ type: "ask", content: WHQ("booking_course") }, "Which course?"], [{ type: "greet", content: null }, "Hello! You can ask me anything!"], + [{ type: "ask", content: WHQ("booking_day") }, "Which day is the lecture?"], */ + + + + [ { type: "answer", @@ -45,6 +84,20 @@ const nlgMapping: NLGMapping = [ }, "The lecture is in G212.", ], + + [ + { + type: "answer", + content: { predicate: "booking_room", argument: "J440" }, + }, + "The lecture is in J440.", + ], + + + + + + ]; export function nlg(moves: Move[]): string { diff --git a/src/rules.ts b/src/rules.ts index 9c24cc0..f7d1b8a 100644 --- a/src/rules.ts +++ b/src/rules.ts @@ -266,7 +266,17 @@ export const rules: Rules = { next_moves: [ ...is.next_moves, { type: "ask", content: q } ], private: { ...is.private, plan: [...is.private.plan.slice(1)] }, }; - } else { + } + if (is.shared.qud.length >0 && Array.isArray(is.shared.lu?.moves) && is.shared.lu?.moves.length === 0) { + const FailedNlu = {type: "FailedNlu", content : null } as Move ; + newIS = { + ...is, + next_moves: [ ...is.next_moves, FailedNlu, { type: "ask", content: q } ], + }; + + } + else { + newIS = { ...is, next_moves: [ ...is.next_moves, { type: "ask", content: q } ], @@ -276,6 +286,24 @@ export const rules: Rules = { } }, + /**rule 3.12 Implement here*/ + + + + selectIcmSemNeg : ({is}) => { + if (Array.isArray(is.shared.lu?.moves) && is.shared.lu?.moves.length === 0) { + const FailedNlu = {type: "FailedNlu", content : null } as Move ; + return () => ({ + ...is, + next_moves : [...is.next_moves, FailedNlu] + }) + } + }, + + + + + /** rule 2.14 */ select_respond: ({ is }) => { if ( @@ -320,6 +348,11 @@ export const rules: Rules = { } }, + + + + + /** only for greet for now */ select_other: ({ is }) => { if (is.private.agenda[0] && is.private.agenda[0].type === "greet") {