Skip to content

Commit

Permalink
Make NLU case-insensitive
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-berman committed Sep 9, 2024
1 parent cdb069c commit 68a9a5a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/is.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import InformationState from "./types";
import { objectsEqual} from "./utils";

export const initialIS = (): InformationState => {
const predicates = {
const predicates = { // Mapping from predicate to sort
favorite_food: "food",
booking_course: "course",
};
const individuals = {
const individuals = { // Mapping from individual to sort
pizza: "food",
LT2319: "course",
};
Expand Down
14 changes: 9 additions & 5 deletions src/nlug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,23 @@ interface NLUMapping {
type NLGMapping = [Move, string][];

const nluMapping: NLUMapping = {
"Where is the lecture?": {
"where is the lecture?": {
type: "ask",
content: (x) => ({"predicate": "booking_room", "argument": x}),
},
"What's your favorite food?": {
"what's your favorite food?": {
type: "ask",
content: (x) => ({"predicate": "favorite_food", "argument": x}),
},
"Pizza": {
"pizza": {
type: "answer",
content: "pizza",
},
"Dialogue Systems 2": {
"dialogue systems 2": {
type: "answer",
content: "LT2319",
},
"dialogue systems": {
type: "answer",
content: "LT2319",
},
Expand Down Expand Up @@ -63,7 +67,7 @@ export function nlg(move: Move | null): string {
*/
export function nlu(utterance: string): Move {
return (
nluMapping[utterance] || {
nluMapping[utterance.toLowerCase()] || {
type: "unknown",
content: "",
}
Expand Down
1 change: 0 additions & 1 deletion src/rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ export const rules: Rules = {
const a = is.shared.lu!.move.content;
if (topQUD && is.shared.lu!.move.type === "answer") {
if (is.domain.relevant(a, topQUD)) {
// TODO (?) should combined proposition be added to domain?
const newIS = {
...is,
shared: {
Expand Down

0 comments on commit 68a9a5a

Please sign in to comment.