Skip to content

Commit

Permalink
lab 1
Browse files Browse the repository at this point in the history
  • Loading branch information
Viktoriada26 committed Oct 1, 2024
1 parent e1d95af commit e0f173c
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/dme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
],
},
Expand Down
55 changes: 54 additions & 1 deletion src/nlug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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."],

Check failure on line 64 in src/nlug.ts

View workflow job for this annotation

GitHub Actions / build

Type '"FailedNlu"' is not assignable to type '"greet" | "request" | "answer" | "ask"'.

/* [{ 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",
Expand All @@ -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 {
Expand Down
35 changes: 34 additions & 1 deletion src/rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 ;

Check failure on line 271 in src/rules.ts

View workflow job for this annotation

GitHub Actions / build

Conversion of type '{ type: "FailedNlu"; content: null; }' to type 'Move' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
newIS = {
...is,
next_moves: [ ...is.next_moves, FailedNlu, { type: "ask", content: q } ],
};

}
else {

newIS = {
...is,
next_moves: [ ...is.next_moves, { type: "ask", content: q } ],
Expand All @@ -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 ;

Check failure on line 295 in src/rules.ts

View workflow job for this annotation

GitHub Actions / build

Conversion of type '{ type: "FailedNlu"; content: null; }' to type 'Move' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
return () => ({
...is,
next_moves : [...is.next_moves, FailedNlu]
})
}
},





/** rule 2.14 */
select_respond: ({ is }) => {
if (
Expand Down Expand Up @@ -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") {
Expand Down

0 comments on commit e0f173c

Please sign in to comment.