@sharpee/parser-en-us 0.9.60-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +123 -0
- package/dist/direction-mappings.d.ts +24 -0
- package/dist/direction-mappings.d.ts.map +1 -0
- package/dist/direction-mappings.js +82 -0
- package/dist/direction-mappings.js.map +1 -0
- package/dist/english-grammar-engine.d.ts +85 -0
- package/dist/english-grammar-engine.d.ts.map +1 -0
- package/dist/english-grammar-engine.js +562 -0
- package/dist/english-grammar-engine.js.map +1 -0
- package/dist/english-parser.d.ts +184 -0
- package/dist/english-parser.d.ts.map +1 -0
- package/dist/english-parser.js +1268 -0
- package/dist/english-parser.js.map +1 -0
- package/dist/english-pattern-compiler.d.ts +29 -0
- package/dist/english-pattern-compiler.d.ts.map +1 -0
- package/dist/english-pattern-compiler.js +211 -0
- package/dist/english-pattern-compiler.js.map +1 -0
- package/dist/grammar.d.ts +19 -0
- package/dist/grammar.d.ts.map +1 -0
- package/dist/grammar.js +620 -0
- package/dist/grammar.js.map +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +44 -0
- package/dist/index.js.map +1 -0
- package/dist/parse-failure.d.ts +59 -0
- package/dist/parse-failure.d.ts.map +1 -0
- package/dist/parse-failure.js +132 -0
- package/dist/parse-failure.js.map +1 -0
- package/dist/parser-types.d.ts +185 -0
- package/dist/parser-types.d.ts.map +1 -0
- package/dist/parser-types.js +134 -0
- package/dist/parser-types.js.map +1 -0
- package/dist/pronoun-context.d.ts +119 -0
- package/dist/pronoun-context.d.ts.map +1 -0
- package/dist/pronoun-context.js +249 -0
- package/dist/pronoun-context.js.map +1 -0
- package/dist/scope-evaluator.d.ts +58 -0
- package/dist/scope-evaluator.d.ts.map +1 -0
- package/dist/scope-evaluator.js +205 -0
- package/dist/scope-evaluator.js.map +1 -0
- package/dist/slot-consumers/entity-slot-consumer.d.ts +36 -0
- package/dist/slot-consumers/entity-slot-consumer.d.ts.map +1 -0
- package/dist/slot-consumers/entity-slot-consumer.js +413 -0
- package/dist/slot-consumers/entity-slot-consumer.js.map +1 -0
- package/dist/slot-consumers/index.d.ts +43 -0
- package/dist/slot-consumers/index.d.ts.map +1 -0
- package/dist/slot-consumers/index.js +78 -0
- package/dist/slot-consumers/index.js.map +1 -0
- package/dist/slot-consumers/slot-consumer.d.ts +61 -0
- package/dist/slot-consumers/slot-consumer.d.ts.map +1 -0
- package/dist/slot-consumers/slot-consumer.js +31 -0
- package/dist/slot-consumers/slot-consumer.js.map +1 -0
- package/dist/slot-consumers/text-slot-consumer.d.ts +33 -0
- package/dist/slot-consumers/text-slot-consumer.d.ts.map +1 -0
- package/dist/slot-consumers/text-slot-consumer.js +157 -0
- package/dist/slot-consumers/text-slot-consumer.js.map +1 -0
- package/dist/slot-consumers/typed-slot-consumer.d.ts +35 -0
- package/dist/slot-consumers/typed-slot-consumer.d.ts.map +1 -0
- package/dist/slot-consumers/typed-slot-consumer.js +151 -0
- package/dist/slot-consumers/typed-slot-consumer.js.map +1 -0
- package/dist/slot-consumers/vocabulary-slot-consumer.d.ts +42 -0
- package/dist/slot-consumers/vocabulary-slot-consumer.d.ts.map +1 -0
- package/dist/slot-consumers/vocabulary-slot-consumer.js +186 -0
- package/dist/slot-consumers/vocabulary-slot-consumer.js.map +1 -0
- package/package.json +65 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Slot Consumer Interface
|
|
3
|
+
* @description Interface for slot consumption strategies (ADR-088)
|
|
4
|
+
*/
|
|
5
|
+
import { SlotType, SlotMatch, CompiledPattern, GrammarContext, SlotConstraint, PatternToken } from '@sharpee/if-domain';
|
|
6
|
+
import { Token } from '@sharpee/if-domain';
|
|
7
|
+
/**
|
|
8
|
+
* Context passed to slot consumers containing all information needed for consumption
|
|
9
|
+
*/
|
|
10
|
+
export interface SlotConsumerContext {
|
|
11
|
+
/** The slot name from the pattern */
|
|
12
|
+
slotName: string;
|
|
13
|
+
/** All tokens in the input */
|
|
14
|
+
tokens: Token[];
|
|
15
|
+
/** Index of the token to start consuming from */
|
|
16
|
+
startIndex: number;
|
|
17
|
+
/** The compiled pattern being matched */
|
|
18
|
+
pattern: CompiledPattern;
|
|
19
|
+
/** Index of this slot in the pattern tokens */
|
|
20
|
+
slotTokenIndex: number;
|
|
21
|
+
/** The grammar rule being matched */
|
|
22
|
+
rule: {
|
|
23
|
+
slots: Map<string, SlotConstraint>;
|
|
24
|
+
[key: string]: any;
|
|
25
|
+
};
|
|
26
|
+
/** Grammar context with world, actor, location */
|
|
27
|
+
context: GrammarContext;
|
|
28
|
+
/** The slot type being consumed */
|
|
29
|
+
slotType: SlotType;
|
|
30
|
+
/** Constraints for this slot */
|
|
31
|
+
slotConstraints?: SlotConstraint;
|
|
32
|
+
/** The pattern token for this slot */
|
|
33
|
+
patternToken?: PatternToken;
|
|
34
|
+
/** Debug mode flag */
|
|
35
|
+
DEBUG?: boolean;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Interface for slot consumption strategies
|
|
39
|
+
* Each consumer handles one or more slot types
|
|
40
|
+
*/
|
|
41
|
+
export interface SlotConsumer {
|
|
42
|
+
/**
|
|
43
|
+
* The slot types this consumer can handle
|
|
44
|
+
*/
|
|
45
|
+
readonly slotTypes: SlotType[];
|
|
46
|
+
/**
|
|
47
|
+
* Attempt to consume tokens for this slot
|
|
48
|
+
* @param ctx The consumption context
|
|
49
|
+
* @returns SlotMatch if successful, null if no match
|
|
50
|
+
*/
|
|
51
|
+
consume(ctx: SlotConsumerContext): SlotMatch | null;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Helper to get the next pattern token after the current slot
|
|
55
|
+
*/
|
|
56
|
+
export declare function getNextPatternToken(ctx: SlotConsumerContext): PatternToken | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* Helper to check if a token matches a pattern delimiter
|
|
59
|
+
*/
|
|
60
|
+
export declare function isPatternDelimiter(token: Token, nextPatternToken: PatternToken | undefined): boolean;
|
|
61
|
+
//# sourceMappingURL=slot-consumer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slot-consumer.d.ts","sourceRoot":"","sources":["../../src/slot-consumers/slot-consumer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,QAAQ,EACR,SAAS,EACT,eAAe,EACf,cAAc,EACd,cAAc,EACd,YAAY,EACb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,qCAAqC;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,8BAA8B;IAC9B,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,iDAAiD;IACjD,UAAU,EAAE,MAAM,CAAC;IACnB,yCAAyC;IACzC,OAAO,EAAE,eAAe,CAAC;IACzB,+CAA+C;IAC/C,cAAc,EAAE,MAAM,CAAC;IACvB,qCAAqC;IACrC,IAAI,EAAE;QACJ,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;QACnC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB,CAAC;IACF,kDAAkD;IAClD,OAAO,EAAE,cAAc,CAAC;IACxB,mCAAmC;IACnC,QAAQ,EAAE,QAAQ,CAAC;IACnB,gCAAgC;IAChC,eAAe,CAAC,EAAE,cAAc,CAAC;IACjC,sCAAsC;IACtC,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,sBAAsB;IACtB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,QAAQ,EAAE,CAAC;IAE/B;;;;OAIG;IACH,OAAO,CAAC,GAAG,EAAE,mBAAmB,GAAG,SAAS,GAAG,IAAI,CAAC;CACrD;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,mBAAmB,GAAG,YAAY,GAAG,SAAS,CAEtF;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,KAAK,EACZ,gBAAgB,EAAE,YAAY,GAAG,SAAS,GACzC,OAAO,CAcT"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @file Slot Consumer Interface
|
|
4
|
+
* @description Interface for slot consumption strategies (ADR-088)
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.getNextPatternToken = getNextPatternToken;
|
|
8
|
+
exports.isPatternDelimiter = isPatternDelimiter;
|
|
9
|
+
/**
|
|
10
|
+
* Helper to get the next pattern token after the current slot
|
|
11
|
+
*/
|
|
12
|
+
function getNextPatternToken(ctx) {
|
|
13
|
+
return ctx.pattern.tokens[ctx.slotTokenIndex + 1];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Helper to check if a token matches a pattern delimiter
|
|
17
|
+
*/
|
|
18
|
+
function isPatternDelimiter(token, nextPatternToken) {
|
|
19
|
+
if (!nextPatternToken)
|
|
20
|
+
return false;
|
|
21
|
+
if (nextPatternToken.type === 'literal' &&
|
|
22
|
+
token.normalized === nextPatternToken.value) {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
if (nextPatternToken.type === 'alternates' &&
|
|
26
|
+
nextPatternToken.alternates.includes(token.normalized)) {
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=slot-consumer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slot-consumer.js","sourceRoot":"","sources":["../../src/slot-consumers/slot-consumer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAgEH,kDAEC;AAKD,gDAiBC;AA3BD;;GAEG;AACH,SAAgB,mBAAmB,CAAC,GAAwB;IAC1D,OAAO,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,cAAc,GAAG,CAAC,CAAC,CAAC;AACpD,CAAC;AAED;;GAEG;AACH,SAAgB,kBAAkB,CAChC,KAAY,EACZ,gBAA0C;IAE1C,IAAI,CAAC,gBAAgB;QAAE,OAAO,KAAK,CAAC;IAEpC,IAAI,gBAAgB,CAAC,IAAI,KAAK,SAAS;QACnC,KAAK,CAAC,UAAU,KAAK,gBAAgB,CAAC,KAAK,EAAE,CAAC;QAChD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,gBAAgB,CAAC,IAAI,KAAK,YAAY;QACtC,gBAAgB,CAAC,UAAW,CAAC,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC;QAC5D,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Text Slot Consumer
|
|
3
|
+
* @description Handles text capture slots (ADR-088)
|
|
4
|
+
*/
|
|
5
|
+
import { SlotType, SlotMatch } from '@sharpee/if-domain';
|
|
6
|
+
import { SlotConsumer, SlotConsumerContext } from './slot-consumer';
|
|
7
|
+
/**
|
|
8
|
+
* Consumer for text slots (TEXT, TEXT_GREEDY, QUOTED_TEXT, TOPIC)
|
|
9
|
+
* Captures raw text without entity resolution
|
|
10
|
+
*/
|
|
11
|
+
export declare class TextSlotConsumer implements SlotConsumer {
|
|
12
|
+
readonly slotTypes: SlotType[];
|
|
13
|
+
consume(ctx: SlotConsumerContext): SlotMatch | null;
|
|
14
|
+
/**
|
|
15
|
+
* Consume a single token as raw text (no entity resolution)
|
|
16
|
+
*/
|
|
17
|
+
private consumeText;
|
|
18
|
+
/**
|
|
19
|
+
* Consume tokens until next pattern element or end (greedy text)
|
|
20
|
+
*/
|
|
21
|
+
private consumeGreedyText;
|
|
22
|
+
/**
|
|
23
|
+
* Consume a quoted text slot
|
|
24
|
+
* Matches text enclosed in double quotes
|
|
25
|
+
*/
|
|
26
|
+
private consumeQuotedText;
|
|
27
|
+
/**
|
|
28
|
+
* Consume a topic slot
|
|
29
|
+
* Consumes one or more words until next pattern element
|
|
30
|
+
*/
|
|
31
|
+
private consumeTopic;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=text-slot-consumer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-slot-consumer.d.ts","sourceRoot":"","sources":["../../src/slot-consumers/text-slot-consumer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAA2C,MAAM,iBAAiB,CAAC;AAE7G;;;GAGG;AACH,qBAAa,gBAAiB,YAAW,YAAY;IACnD,QAAQ,CAAC,SAAS,aAKhB;IAEF,OAAO,CAAC,GAAG,EAAE,mBAAmB,GAAG,SAAS,GAAG,IAAI;IAiBnD;;OAEG;IACH,OAAO,CAAC,WAAW;IAgBnB;;OAEG;IACH,OAAO,CAAC,iBAAiB;IA8BzB;;;OAGG;IACH,OAAO,CAAC,iBAAiB;IAmDzB;;;OAGG;IACH,OAAO,CAAC,YAAY;CAkCrB"}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @file Text Slot Consumer
|
|
4
|
+
* @description Handles text capture slots (ADR-088)
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.TextSlotConsumer = void 0;
|
|
8
|
+
const if_domain_1 = require("@sharpee/if-domain");
|
|
9
|
+
const slot_consumer_1 = require("./slot-consumer");
|
|
10
|
+
/**
|
|
11
|
+
* Consumer for text slots (TEXT, TEXT_GREEDY, QUOTED_TEXT, TOPIC)
|
|
12
|
+
* Captures raw text without entity resolution
|
|
13
|
+
*/
|
|
14
|
+
class TextSlotConsumer {
|
|
15
|
+
slotTypes = [
|
|
16
|
+
if_domain_1.SlotType.TEXT,
|
|
17
|
+
if_domain_1.SlotType.TEXT_GREEDY,
|
|
18
|
+
if_domain_1.SlotType.QUOTED_TEXT,
|
|
19
|
+
if_domain_1.SlotType.TOPIC
|
|
20
|
+
];
|
|
21
|
+
consume(ctx) {
|
|
22
|
+
const { slotType } = ctx;
|
|
23
|
+
switch (slotType) {
|
|
24
|
+
case if_domain_1.SlotType.TEXT:
|
|
25
|
+
return this.consumeText(ctx);
|
|
26
|
+
case if_domain_1.SlotType.TEXT_GREEDY:
|
|
27
|
+
return this.consumeGreedyText(ctx);
|
|
28
|
+
case if_domain_1.SlotType.QUOTED_TEXT:
|
|
29
|
+
return this.consumeQuotedText(ctx);
|
|
30
|
+
case if_domain_1.SlotType.TOPIC:
|
|
31
|
+
return this.consumeTopic(ctx);
|
|
32
|
+
default:
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Consume a single token as raw text (no entity resolution)
|
|
38
|
+
*/
|
|
39
|
+
consumeText(ctx) {
|
|
40
|
+
const { tokens, startIndex, slotType } = ctx;
|
|
41
|
+
if (startIndex >= tokens.length) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
const token = tokens[startIndex];
|
|
45
|
+
return {
|
|
46
|
+
tokens: [startIndex],
|
|
47
|
+
text: token.word,
|
|
48
|
+
confidence: 1.0,
|
|
49
|
+
slotType
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Consume tokens until next pattern element or end (greedy text)
|
|
54
|
+
*/
|
|
55
|
+
consumeGreedyText(ctx) {
|
|
56
|
+
const { tokens, startIndex, slotType } = ctx;
|
|
57
|
+
const nextPatternToken = (0, slot_consumer_1.getNextPatternToken)(ctx);
|
|
58
|
+
const consumedIndices = [];
|
|
59
|
+
const consumedWords = [];
|
|
60
|
+
for (let i = startIndex; i < tokens.length; i++) {
|
|
61
|
+
const token = tokens[i];
|
|
62
|
+
// Check if this token matches the next pattern element (delimiter)
|
|
63
|
+
if ((0, slot_consumer_1.isPatternDelimiter)(token, nextPatternToken)) {
|
|
64
|
+
break; // Stop - this token belongs to next pattern element
|
|
65
|
+
}
|
|
66
|
+
consumedIndices.push(i);
|
|
67
|
+
consumedWords.push(token.word);
|
|
68
|
+
}
|
|
69
|
+
if (consumedIndices.length === 0) {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
tokens: consumedIndices,
|
|
74
|
+
text: consumedWords.join(' '),
|
|
75
|
+
confidence: 1.0,
|
|
76
|
+
slotType
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Consume a quoted text slot
|
|
81
|
+
* Matches text enclosed in double quotes
|
|
82
|
+
*/
|
|
83
|
+
consumeQuotedText(ctx) {
|
|
84
|
+
const { tokens, startIndex } = ctx;
|
|
85
|
+
if (startIndex >= tokens.length) {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
const token = tokens[startIndex];
|
|
89
|
+
const word = token.word;
|
|
90
|
+
// Check if token starts with quote
|
|
91
|
+
if (!word.startsWith('"')) {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
// Single token quoted text: "hello"
|
|
95
|
+
if (word.endsWith('"') && word.length > 2) {
|
|
96
|
+
return {
|
|
97
|
+
tokens: [startIndex],
|
|
98
|
+
text: word.slice(1, -1), // Remove quotes
|
|
99
|
+
confidence: 1.0,
|
|
100
|
+
slotType: if_domain_1.SlotType.QUOTED_TEXT
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
// Multi-token quoted text: "hello world"
|
|
104
|
+
// Consume tokens until closing quote
|
|
105
|
+
const consumedIndices = [startIndex];
|
|
106
|
+
const consumedWords = [word.slice(1)]; // Remove opening quote
|
|
107
|
+
for (let i = startIndex + 1; i < tokens.length; i++) {
|
|
108
|
+
const t = tokens[i];
|
|
109
|
+
consumedIndices.push(i);
|
|
110
|
+
if (t.word.endsWith('"')) {
|
|
111
|
+
consumedWords.push(t.word.slice(0, -1)); // Remove closing quote
|
|
112
|
+
return {
|
|
113
|
+
tokens: consumedIndices,
|
|
114
|
+
text: consumedWords.join(' '),
|
|
115
|
+
confidence: 1.0,
|
|
116
|
+
slotType: if_domain_1.SlotType.QUOTED_TEXT
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
consumedWords.push(t.word);
|
|
120
|
+
}
|
|
121
|
+
// No closing quote found
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Consume a topic slot
|
|
126
|
+
* Consumes one or more words until next pattern element
|
|
127
|
+
*/
|
|
128
|
+
consumeTopic(ctx) {
|
|
129
|
+
const { tokens, startIndex } = ctx;
|
|
130
|
+
if (startIndex >= tokens.length) {
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
const nextPatternToken = (0, slot_consumer_1.getNextPatternToken)(ctx);
|
|
134
|
+
const consumedIndices = [];
|
|
135
|
+
const consumedWords = [];
|
|
136
|
+
for (let i = startIndex; i < tokens.length; i++) {
|
|
137
|
+
const token = tokens[i];
|
|
138
|
+
// Check for pattern delimiter
|
|
139
|
+
if ((0, slot_consumer_1.isPatternDelimiter)(token, nextPatternToken)) {
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
consumedIndices.push(i);
|
|
143
|
+
consumedWords.push(token.word);
|
|
144
|
+
}
|
|
145
|
+
if (consumedIndices.length === 0) {
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
return {
|
|
149
|
+
tokens: consumedIndices,
|
|
150
|
+
text: consumedWords.join(' '),
|
|
151
|
+
confidence: 1.0,
|
|
152
|
+
slotType: if_domain_1.SlotType.TOPIC
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
exports.TextSlotConsumer = TextSlotConsumer;
|
|
157
|
+
//# sourceMappingURL=text-slot-consumer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-slot-consumer.js","sourceRoot":"","sources":["../../src/slot-consumers/text-slot-consumer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kDAAyD;AACzD,mDAA6G;AAE7G;;;GAGG;AACH,MAAa,gBAAgB;IAClB,SAAS,GAAG;QACnB,oBAAQ,CAAC,IAAI;QACb,oBAAQ,CAAC,WAAW;QACpB,oBAAQ,CAAC,WAAW;QACpB,oBAAQ,CAAC,KAAK;KACf,CAAC;IAEF,OAAO,CAAC,GAAwB;QAC9B,MAAM,EAAE,QAAQ,EAAE,GAAG,GAAG,CAAC;QAEzB,QAAQ,QAAQ,EAAE,CAAC;YACjB,KAAK,oBAAQ,CAAC,IAAI;gBAChB,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;YAC/B,KAAK,oBAAQ,CAAC,WAAW;gBACvB,OAAO,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC;YACrC,KAAK,oBAAQ,CAAC,WAAW;gBACvB,OAAO,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC;YACrC,KAAK,oBAAQ,CAAC,KAAK;gBACjB,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;YAChC;gBACE,OAAO,IAAI,CAAC;QAChB,CAAC;IACH,CAAC;IAED;;OAEG;IACK,WAAW,CAAC,GAAwB;QAC1C,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,GAAG,CAAC;QAE7C,IAAI,UAAU,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YAChC,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,KAAK,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;QACjC,OAAO;YACL,MA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
+
* @file Typed Slot Consumer
|
|
3
|
+
* @description Handles typed value slots (ADR-088, ADR-082)
|
|
4
|
+
*/
|
|
5
|
+
import { SlotType, SlotMatch } from '@sharpee/if-domain';
|
|
6
|
+
import { SlotConsumer, SlotConsumerContext } from './slot-consumer';
|
|
7
|
+
/**
|
|
8
|
+
* Consumer for typed value slots (NUMBER, ORDINAL, TIME, DIRECTION)
|
|
9
|
+
* Validates input matches expected format/vocabulary
|
|
10
|
+
*/
|
|
11
|
+
export declare class TypedSlotConsumer implements SlotConsumer {
|
|
12
|
+
readonly slotTypes: SlotType[];
|
|
13
|
+
consume(ctx: SlotConsumerContext): SlotMatch | null;
|
|
14
|
+
/**
|
|
15
|
+
* Consume a number slot (integer)
|
|
16
|
+
* Matches digits (1, 29, 100) or words (one, twenty)
|
|
17
|
+
*/
|
|
18
|
+
private consumeNumber;
|
|
19
|
+
/**
|
|
20
|
+
* Consume an ordinal slot
|
|
21
|
+
* Matches ordinal words (first, second) or suffixed numbers (1st, 2nd)
|
|
22
|
+
*/
|
|
23
|
+
private consumeOrdinal;
|
|
24
|
+
/**
|
|
25
|
+
* Consume a time slot
|
|
26
|
+
* Matches HH:MM format (10:40, 6:00)
|
|
27
|
+
*/
|
|
28
|
+
private consumeTime;
|
|
29
|
+
/**
|
|
30
|
+
* Consume a direction slot
|
|
31
|
+
* Matches built-in direction vocabulary (n, north, up, etc.)
|
|
32
|
+
*/
|
|
33
|
+
private consumeDirection;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=typed-slot-consumer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typed-slot-consumer.d.ts","sourceRoot":"","sources":["../../src/slot-consumers/typed-slot-consumer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEzD,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEpE;;;GAGG;AACH,qBAAa,iBAAkB,YAAW,YAAY;IACpD,QAAQ,CAAC,SAAS,aAKhB;IAEF,OAAO,CAAC,GAAG,EAAE,mBAAmB,GAAG,SAAS,GAAG,IAAI;IAiBnD;;;OAGG;IACH,OAAO,CAAC,aAAa;IAiCrB;;;OAGG;IACH,OAAO,CAAC,cAAc;IAkCtB;;;OAGG;IACH,OAAO,CAAC,WAAW;IA8BnB;;;OAGG;IACH,OAAO,CAAC,gBAAgB;CAsBzB"}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @file Typed Slot Consumer
|
|
4
|
+
* @description Handles typed value slots (ADR-088, ADR-082)
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.TypedSlotConsumer = void 0;
|
|
8
|
+
const if_domain_1 = require("@sharpee/if-domain");
|
|
9
|
+
const lang_en_us_1 = require("@sharpee/lang-en-us");
|
|
10
|
+
/**
|
|
11
|
+
* Consumer for typed value slots (NUMBER, ORDINAL, TIME, DIRECTION)
|
|
12
|
+
* Validates input matches expected format/vocabulary
|
|
13
|
+
*/
|
|
14
|
+
class TypedSlotConsumer {
|
|
15
|
+
slotTypes = [
|
|
16
|
+
if_domain_1.SlotType.NUMBER,
|
|
17
|
+
if_domain_1.SlotType.ORDINAL,
|
|
18
|
+
if_domain_1.SlotType.TIME,
|
|
19
|
+
if_domain_1.SlotType.DIRECTION
|
|
20
|
+
];
|
|
21
|
+
consume(ctx) {
|
|
22
|
+
const { slotType } = ctx;
|
|
23
|
+
switch (slotType) {
|
|
24
|
+
case if_domain_1.SlotType.NUMBER:
|
|
25
|
+
return this.consumeNumber(ctx);
|
|
26
|
+
case if_domain_1.SlotType.ORDINAL:
|
|
27
|
+
return this.consumeOrdinal(ctx);
|
|
28
|
+
case if_domain_1.SlotType.TIME:
|
|
29
|
+
return this.consumeTime(ctx);
|
|
30
|
+
case if_domain_1.SlotType.DIRECTION:
|
|
31
|
+
return this.consumeDirection(ctx);
|
|
32
|
+
default:
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Consume a number slot (integer)
|
|
38
|
+
* Matches digits (1, 29, 100) or words (one, twenty)
|
|
39
|
+
*/
|
|
40
|
+
consumeNumber(ctx) {
|
|
41
|
+
const { tokens, startIndex } = ctx;
|
|
42
|
+
if (startIndex >= tokens.length) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
const token = tokens[startIndex];
|
|
46
|
+
const normalized = token.normalized;
|
|
47
|
+
// Check word form (using imported vocabulary from lang-en-us)
|
|
48
|
+
if (normalized in lang_en_us_1.cardinalNumbers) {
|
|
49
|
+
return {
|
|
50
|
+
tokens: [startIndex],
|
|
51
|
+
text: token.word,
|
|
52
|
+
confidence: 1.0,
|
|
53
|
+
slotType: if_domain_1.SlotType.NUMBER
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
// Check digit form
|
|
57
|
+
if (/^\d+$/.test(normalized)) {
|
|
58
|
+
return {
|
|
59
|
+
tokens: [startIndex],
|
|
60
|
+
text: token.word,
|
|
61
|
+
confidence: 1.0,
|
|
62
|
+
slotType: if_domain_1.SlotType.NUMBER
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Consume an ordinal slot
|
|
69
|
+
* Matches ordinal words (first, second) or suffixed numbers (1st, 2nd)
|
|
70
|
+
*/
|
|
71
|
+
consumeOrdinal(ctx) {
|
|
72
|
+
const { tokens, startIndex } = ctx;
|
|
73
|
+
if (startIndex >= tokens.length) {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
const token = tokens[startIndex];
|
|
77
|
+
const normalized = token.normalized;
|
|
78
|
+
// Check word form (using imported vocabulary from lang-en-us)
|
|
79
|
+
if (normalized in lang_en_us_1.ordinalNumbers) {
|
|
80
|
+
return {
|
|
81
|
+
tokens: [startIndex],
|
|
82
|
+
text: token.word,
|
|
83
|
+
confidence: 1.0,
|
|
84
|
+
slotType: if_domain_1.SlotType.ORDINAL
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
// Check suffixed number form (1st, 2nd, 3rd, 4th, etc.)
|
|
88
|
+
const ordinalMatch = normalized.match(/^(\d+)(st|nd|rd|th)$/);
|
|
89
|
+
if (ordinalMatch) {
|
|
90
|
+
return {
|
|
91
|
+
tokens: [startIndex],
|
|
92
|
+
text: token.word,
|
|
93
|
+
confidence: 1.0,
|
|
94
|
+
slotType: if_domain_1.SlotType.ORDINAL
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Consume a time slot
|
|
101
|
+
* Matches HH:MM format (10:40, 6:00)
|
|
102
|
+
*/
|
|
103
|
+
consumeTime(ctx) {
|
|
104
|
+
const { tokens, startIndex } = ctx;
|
|
105
|
+
if (startIndex >= tokens.length) {
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
const token = tokens[startIndex];
|
|
109
|
+
const word = token.word;
|
|
110
|
+
// Match HH:MM format
|
|
111
|
+
const timeMatch = word.match(/^(\d{1,2}):(\d{2})$/);
|
|
112
|
+
if (timeMatch) {
|
|
113
|
+
const hours = parseInt(timeMatch[1], 10);
|
|
114
|
+
const minutes = parseInt(timeMatch[2], 10);
|
|
115
|
+
// Validate time range
|
|
116
|
+
if (hours >= 0 && hours <= 23 && minutes >= 0 && minutes <= 59) {
|
|
117
|
+
return {
|
|
118
|
+
tokens: [startIndex],
|
|
119
|
+
text: word,
|
|
120
|
+
confidence: 1.0,
|
|
121
|
+
slotType: if_domain_1.SlotType.TIME
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Consume a direction slot
|
|
129
|
+
* Matches built-in direction vocabulary (n, north, up, etc.)
|
|
130
|
+
*/
|
|
131
|
+
consumeDirection(ctx) {
|
|
132
|
+
const { tokens, startIndex } = ctx;
|
|
133
|
+
if (startIndex >= tokens.length) {
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
const token = tokens[startIndex];
|
|
137
|
+
const normalized = token.normalized;
|
|
138
|
+
// Check direction vocabulary (using imported vocabulary from lang-en-us)
|
|
139
|
+
if (normalized in lang_en_us_1.directionMap) {
|
|
140
|
+
return {
|
|
141
|
+
tokens: [startIndex],
|
|
142
|
+
text: token.word,
|
|
143
|
+
confidence: 1.0,
|
|
144
|
+
slotType: if_domain_1.SlotType.DIRECTION
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
exports.TypedSlotConsumer = TypedSlotConsumer;
|
|
151
|
+
//# sourceMappingURL=typed-slot-consumer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typed-slot-consumer.js","sourceRoot":"","sources":["../../src/slot-consumers/typed-slot-consumer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kDAAyD;AACzD,oDAAoF;AAGpF;;;GAGG;AACH,MAAa,iBAAiB;IACnB,SAAS,GAAG;QACnB,oBAAQ,CAAC,MAAM;QACf,oBAAQ,CAAC,OAAO;QAChB,oBAAQ,CAAC,IAAI;QACb,oBAAQ,CAAC,SAAS;KACnB,CAAC;IAEF,OAAO,CAAC,GAAwB;QAC9B,MAAM,EAAE,QAAQ,EAAE,GAAG,GAAG,CAAC;QAEzB,QAAQ,QAAQ,EAAE,CAAC;YACjB,KAAK,oBAAQ,CAAC,MAAM;gBAClB,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;YACjC,KAAK,oBAAQ,CAAC,OAAO;gBACnB,OAAO,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;YAClC,KAAK,o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;YACtB,IAAI,KAAK,IAAI,CAAC,IAAI,KAAK,IAAI,EAAE,IAAI,OAAO,IAAI,CAAC,IAAI,OAAO,IAAI,EAAE,EAAE,CAAC;gBAC/D,OAAO;oBACL,MAAM,EAAE,CAAC,UAAU,CAAC;oBACpB,IAAI,EAAE,IAAI;oBACV,UAAU,EAAE,GAAG;oBACf,QAAQ,EAAE,oBAAQ,CAAC,IAAI;iBACxB,CAAC;YACJ,CAAC;QACH,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;OAGG;IACK,gBAAgB,CAAC,GAAwB;QAC/C,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,GAAG,CAAC;QAEnC,IAAI,UAAU,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YAChC,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,KAAK,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;QACjC,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC;QAEpC,yEAAyE;QACzE,IAAI,UAAU,IAAI,yBAAY,EAAE,CAAC;YAC/B,OAAO;gBACL,MAAM,EAAE,CAAC,UAAU,CAAC;gBACpB,IAAI,EAAE,KAAK,CAAC,IAAI;gBAChB,UAAU,EAAE,GAAG;gBACf,QAAQ,EAAE,oBAAQ,CAAC,SAAS;aAC7B,CAAC;QACJ,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAhKD,8CAgKC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Vocabulary Slot Consumer
|
|
3
|
+
* @description Handles vocabulary-constrained slots (ADR-088, ADR-082)
|
|
4
|
+
*/
|
|
5
|
+
import { SlotType, SlotMatch } from '@sharpee/if-domain';
|
|
6
|
+
import { SlotConsumer, SlotConsumerContext } from './slot-consumer';
|
|
7
|
+
/**
|
|
8
|
+
* Consumer for vocabulary-constrained slots (ADJECTIVE, NOUN, VOCABULARY, MANNER)
|
|
9
|
+
* Validates input against registered vocabulary categories
|
|
10
|
+
*/
|
|
11
|
+
export declare class VocabularySlotConsumer implements SlotConsumer {
|
|
12
|
+
readonly slotTypes: SlotType[];
|
|
13
|
+
consume(ctx: SlotConsumerContext): SlotMatch | null;
|
|
14
|
+
/**
|
|
15
|
+
* Consume an adjective slot from story vocabulary
|
|
16
|
+
* Requires vocabulary to be registered via language provider
|
|
17
|
+
*/
|
|
18
|
+
private consumeAdjective;
|
|
19
|
+
/**
|
|
20
|
+
* Consume a noun slot from story vocabulary
|
|
21
|
+
* Requires vocabulary to be registered via language provider
|
|
22
|
+
*/
|
|
23
|
+
private consumeNoun;
|
|
24
|
+
/**
|
|
25
|
+
* Consume a vocabulary slot from a story-defined category.
|
|
26
|
+
* Uses GrammarVocabularyProvider to check if word is in category
|
|
27
|
+
* and if the category is active in the current context.
|
|
28
|
+
*/
|
|
29
|
+
private consumeVocabulary;
|
|
30
|
+
/**
|
|
31
|
+
* Consume a manner adverb slot.
|
|
32
|
+
* Matches built-in manner adverbs plus any story-defined extensions.
|
|
33
|
+
* The matched manner is intended to feed into command.intention.manner
|
|
34
|
+
*/
|
|
35
|
+
private consumeManner;
|
|
36
|
+
/**
|
|
37
|
+
* Get vocabulary set from context
|
|
38
|
+
* Returns null if vocabulary not available
|
|
39
|
+
*/
|
|
40
|
+
private getVocabulary;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=vocabulary-slot-consumer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vocabulary-slot-consumer.d.ts","sourceRoot":"","sources":["../../src/slot-consumers/vocabulary-slot-consumer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAkB,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAapE;;;GAGG;AACH,qBAAa,sBAAuB,YAAW,YAAY;IACzD,QAAQ,CAAC,SAAS,aAKhB;IAEF,OAAO,CAAC,GAAG,EAAE,mBAAmB,GAAG,SAAS,GAAG,IAAI;IAiBnD;;;OAGG;IACH,OAAO,CAAC,gBAAgB;IAyBxB;;;OAGG;IACH,OAAO,CAAC,WAAW;IAyBnB;;;;OAIG;IACH,OAAO,CAAC,iBAAiB;IAmCzB;;;;OAIG;IACH,OAAO,CAAC,aAAa;IAuCrB;;;OAGG;IACH,OAAO,CAAC,aAAa;CAqBtB"}
|