From e0f173cb0ba2907964053f506ced3767609e6933 Mon Sep 17 00:00:00 2001 From: "danivictori26@gmail.com" Date: Tue, 1 Oct 2024 23:36:12 +0200 Subject: [PATCH 1/3] lab 1 --- src/dme.ts | 1 + src/nlug.ts | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++- src/rules.ts | 35 ++++++++++++++++++++++++++++++++- 3 files changed, 89 insertions(+), 2 deletions(-) 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") { From 0d3bcb4d62bf14e5636319f1f404ab5d31c3e1ac Mon Sep 17 00:00:00 2001 From: "danivictori26@gmail.com" Date: Tue, 15 Oct 2024 11:38:07 +0200 Subject: [PATCH 2/3] dme tests --- test/dme.test.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/dme.test.ts b/test/dme.test.ts index de53be1..35961a1 100644 --- a/test/dme.test.ts +++ b/test/dme.test.ts @@ -138,7 +138,21 @@ describe("DME tests", () => { { speaker: "usr", message: "Where is the lecture?" }, { speaker: "sys", message: "Which course?" }, { speaker: "usr", message: "Dialogue Systems 2" }, + { speaker: "sys", message: "Which day is the lecture?" }, + { speaker: "usr", message: "monday" }, { speaker: "sys", message: "The lecture is in G212." }, ]); }); + describe("system answer in NLU", () => { + runTest([ + { speaker: "sys", message: "Hello! You can ask me anything!" }, + { speaker: "usr", message: "blabla" }, + { speaker: "sys", message: "I am sorry, I don't understand you." }, + { speaker: "usr", message: "Where is the lecture?" }, + { speaker: "sys", message: "Which course?" }, + { speaker: "usr", message: "blabla" }, + { speaker: "sys", message: "I am sorry, I don't understand you. Which course?" }, + ]); + }); + }); From e4a92f531d8bed74b64905a0c2de133455560c3b Mon Sep 17 00:00:00 2001 From: "danivictori26@gmail.com" Date: Thu, 17 Oct 2024 21:32:34 +0200 Subject: [PATCH 3/3] is.ts --- src/is.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/is.ts b/src/is.ts index 0975cb1..75eeab4 100644 --- a/src/is.ts +++ b/src/is.ts @@ -12,11 +12,15 @@ export const initialIS = (): InformationState => { // Mapping from predicate to sort favorite_food: "food", booking_course: "course", + booking_day : "day", }; const individuals: { [index: string]: string } = { // Mapping from individual to sort pizza: "food", LT2319: "course", + thursday : "day", + monday : "day", + }; return { domain: { @@ -58,6 +62,7 @@ export const initialIS = (): InformationState => { content: WHQ("booking_room"), plan: [ findout(WHQ("booking_course")), + findout(WHQ("booking_day")), consultDB(WHQ("booking_room")), ], }, @@ -67,12 +72,19 @@ export const initialIS = (): InformationState => { consultDB: (question, facts) => { if (objectsEqual(question, WHQ("booking_room"))) { const course = getFactArgument(facts, "booking_course"); - if (course == "LT2319") { + const booking_day = getFactArgument(facts, "booking_day"); + if (course == "LT2319" && booking_day == "monday") { return { predicate: "booking_room", argument: "G212" }; } + if (course == "LT2319" && booking_day == "thursday") { + return { predicate: "booking_room", argument: "J440" }; + } } + return null; }, + + }, next_moves: [], private: {