@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.
Files changed (67) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +123 -0
  3. package/dist/direction-mappings.d.ts +24 -0
  4. package/dist/direction-mappings.d.ts.map +1 -0
  5. package/dist/direction-mappings.js +82 -0
  6. package/dist/direction-mappings.js.map +1 -0
  7. package/dist/english-grammar-engine.d.ts +85 -0
  8. package/dist/english-grammar-engine.d.ts.map +1 -0
  9. package/dist/english-grammar-engine.js +562 -0
  10. package/dist/english-grammar-engine.js.map +1 -0
  11. package/dist/english-parser.d.ts +184 -0
  12. package/dist/english-parser.d.ts.map +1 -0
  13. package/dist/english-parser.js +1268 -0
  14. package/dist/english-parser.js.map +1 -0
  15. package/dist/english-pattern-compiler.d.ts +29 -0
  16. package/dist/english-pattern-compiler.d.ts.map +1 -0
  17. package/dist/english-pattern-compiler.js +211 -0
  18. package/dist/english-pattern-compiler.js.map +1 -0
  19. package/dist/grammar.d.ts +19 -0
  20. package/dist/grammar.d.ts.map +1 -0
  21. package/dist/grammar.js +620 -0
  22. package/dist/grammar.js.map +1 -0
  23. package/dist/index.d.ts +24 -0
  24. package/dist/index.d.ts.map +1 -0
  25. package/dist/index.js +44 -0
  26. package/dist/index.js.map +1 -0
  27. package/dist/parse-failure.d.ts +59 -0
  28. package/dist/parse-failure.d.ts.map +1 -0
  29. package/dist/parse-failure.js +132 -0
  30. package/dist/parse-failure.js.map +1 -0
  31. package/dist/parser-types.d.ts +185 -0
  32. package/dist/parser-types.d.ts.map +1 -0
  33. package/dist/parser-types.js +134 -0
  34. package/dist/parser-types.js.map +1 -0
  35. package/dist/pronoun-context.d.ts +119 -0
  36. package/dist/pronoun-context.d.ts.map +1 -0
  37. package/dist/pronoun-context.js +249 -0
  38. package/dist/pronoun-context.js.map +1 -0
  39. package/dist/scope-evaluator.d.ts +58 -0
  40. package/dist/scope-evaluator.d.ts.map +1 -0
  41. package/dist/scope-evaluator.js +205 -0
  42. package/dist/scope-evaluator.js.map +1 -0
  43. package/dist/slot-consumers/entity-slot-consumer.d.ts +36 -0
  44. package/dist/slot-consumers/entity-slot-consumer.d.ts.map +1 -0
  45. package/dist/slot-consumers/entity-slot-consumer.js +413 -0
  46. package/dist/slot-consumers/entity-slot-consumer.js.map +1 -0
  47. package/dist/slot-consumers/index.d.ts +43 -0
  48. package/dist/slot-consumers/index.d.ts.map +1 -0
  49. package/dist/slot-consumers/index.js +78 -0
  50. package/dist/slot-consumers/index.js.map +1 -0
  51. package/dist/slot-consumers/slot-consumer.d.ts +61 -0
  52. package/dist/slot-consumers/slot-consumer.d.ts.map +1 -0
  53. package/dist/slot-consumers/slot-consumer.js +31 -0
  54. package/dist/slot-consumers/slot-consumer.js.map +1 -0
  55. package/dist/slot-consumers/text-slot-consumer.d.ts +33 -0
  56. package/dist/slot-consumers/text-slot-consumer.d.ts.map +1 -0
  57. package/dist/slot-consumers/text-slot-consumer.js +157 -0
  58. package/dist/slot-consumers/text-slot-consumer.js.map +1 -0
  59. package/dist/slot-consumers/typed-slot-consumer.d.ts +35 -0
  60. package/dist/slot-consumers/typed-slot-consumer.d.ts.map +1 -0
  61. package/dist/slot-consumers/typed-slot-consumer.js +151 -0
  62. package/dist/slot-consumers/typed-slot-consumer.js.map +1 -0
  63. package/dist/slot-consumers/vocabulary-slot-consumer.d.ts +42 -0
  64. package/dist/slot-consumers/vocabulary-slot-consumer.d.ts.map +1 -0
  65. package/dist/slot-consumers/vocabulary-slot-consumer.js +186 -0
  66. package/dist/slot-consumers/vocabulary-slot-consumer.js.map +1 -0
  67. package/package.json +65 -0
@@ -0,0 +1,36 @@
1
+ /**
2
+ * @file Entity Slot Consumer
3
+ * @description Handles entity resolution slots including multi-object parsing (ADR-088)
4
+ * and pronoun resolution (ADR-089)
5
+ */
6
+ import { SlotType, SlotMatch } from '@sharpee/if-domain';
7
+ import { SlotConsumer, SlotConsumerContext } from './slot-consumer';
8
+ /**
9
+ * Consumer for entity slots (ENTITY, INSTRUMENT)
10
+ * Handles multi-object parsing: "all", "all but X", "X and Y"
11
+ */
12
+ export declare class EntitySlotConsumer implements SlotConsumer {
13
+ readonly slotTypes: SlotType[];
14
+ consume(ctx: SlotConsumerContext): SlotMatch | null;
15
+ /**
16
+ * Try to resolve a pronoun token using the pronoun context (ADR-089)
17
+ */
18
+ private tryResolvePronoun;
19
+ /**
20
+ * Consume "all" and optionally "all but/except X"
21
+ */
22
+ private consumeAllSlot;
23
+ /**
24
+ * Consume entities after "but/except" with "and" support
25
+ */
26
+ private consumeExcludedEntities;
27
+ /**
28
+ * Consume entity slot with "and" list detection
29
+ */
30
+ private consumeEntityWithListDetection;
31
+ /**
32
+ * Evaluate slot constraints and return confidence
33
+ */
34
+ private evaluateSlotConstraints;
35
+ }
36
+ //# sourceMappingURL=entity-slot-consumer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity-slot-consumer.d.ts","sourceRoot":"","sources":["../../src/slot-consumers/entity-slot-consumer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,QAAQ,EACR,SAAS,EAKV,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAA2C,MAAM,iBAAiB,CAAC;AAI7G;;;GAGG;AACH,qBAAa,kBAAmB,YAAW,YAAY;IACrD,QAAQ,CAAC,SAAS,aAA0C;IAE5D,OAAO,CAAC,GAAG,EAAE,mBAAmB,GAAG,SAAS,GAAG,IAAI;IAsCnD;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAgEzB;;OAEG;IACH,OAAO,CAAC,cAAc;IA2CtB;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAiE/B;;OAEG;IACH,OAAO,CAAC,8BAA8B;IA0KtC;;OAEG;IACH,OAAO,CAAC,uBAAuB;CAuEhC"}
@@ -0,0 +1,413 @@
1
+ "use strict";
2
+ /**
3
+ * @file Entity Slot Consumer
4
+ * @description Handles entity resolution slots including multi-object parsing (ADR-088)
5
+ * and pronoun resolution (ADR-089)
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.EntitySlotConsumer = void 0;
9
+ const if_domain_1 = require("@sharpee/if-domain");
10
+ const slot_consumer_1 = require("./slot-consumer");
11
+ const scope_evaluator_1 = require("../scope-evaluator");
12
+ const pronoun_context_1 = require("../pronoun-context");
13
+ /**
14
+ * Consumer for entity slots (ENTITY, INSTRUMENT)
15
+ * Handles multi-object parsing: "all", "all but X", "X and Y"
16
+ */
17
+ class EntitySlotConsumer {
18
+ slotTypes = [if_domain_1.SlotType.ENTITY, if_domain_1.SlotType.INSTRUMENT];
19
+ consume(ctx) {
20
+ const { tokens, startIndex, slotType } = ctx;
21
+ const DEBUG = ctx.DEBUG || false;
22
+ const nextPatternToken = (0, slot_consumer_1.getNextPatternToken)(ctx);
23
+ // Check for pronoun at start (ADR-089)
24
+ if (startIndex < tokens.length) {
25
+ const firstWord = tokens[startIndex].normalized;
26
+ if (DEBUG) {
27
+ console.log(`consumeEntitySlot: startIndex=${startIndex}, token.word='${tokens[startIndex]?.word}', token.normalized='${firstWord}'`);
28
+ }
29
+ // Try to resolve as pronoun first
30
+ if ((0, pronoun_context_1.isRecognizedPronoun)(firstWord)) {
31
+ const pronounResult = this.tryResolvePronoun(ctx, firstWord, DEBUG);
32
+ if (pronounResult) {
33
+ return pronounResult;
34
+ }
35
+ // If pronoun resolution failed, fall through to standard entity resolution
36
+ // This handles cases like "take it" when there's no previous object
37
+ if (DEBUG) {
38
+ console.log(`Pronoun '${firstWord}' could not be resolved, trying standard entity resolution`);
39
+ }
40
+ }
41
+ }
42
+ // Check for "all" keyword at start
43
+ if (startIndex < tokens.length && tokens[startIndex].normalized === 'all') {
44
+ if (DEBUG) {
45
+ console.log('Detected "all" keyword, calling consumeAllSlot');
46
+ }
47
+ return this.consumeAllSlot(ctx, nextPatternToken, DEBUG);
48
+ }
49
+ // Standard entity consumption with "and" list detection
50
+ return this.consumeEntityWithListDetection(ctx, DEBUG);
51
+ }
52
+ /**
53
+ * Try to resolve a pronoun token using the pronoun context (ADR-089)
54
+ */
55
+ tryResolvePronoun(ctx, pronoun, DEBUG) {
56
+ const { tokens, startIndex, slotType, context } = ctx;
57
+ const pronounContext = (0, pronoun_context_1.getPronounContextManager)();
58
+ if (!pronounContext) {
59
+ if (DEBUG) {
60
+ console.log('No pronoun context manager available');
61
+ }
62
+ return null;
63
+ }
64
+ const resolved = pronounContext.resolve(pronoun);
65
+ if (!resolved || resolved.length === 0) {
66
+ if (DEBUG) {
67
+ console.log(`Pronoun '${pronoun}' did not resolve to any entity`);
68
+ }
69
+ return null;
70
+ }
71
+ if (DEBUG) {
72
+ console.log(`Pronoun '${pronoun}' resolved to: ${resolved.map(r => r.entityId).join(', ')}`);
73
+ }
74
+ // Single entity resolution
75
+ if (resolved.length === 1) {
76
+ const ref = resolved[0];
77
+ // Use resolved entity's original text for entity resolution
78
+ // Store pronoun metadata as extended properties
79
+ const result = {
80
+ tokens: [startIndex],
81
+ text: ref.text, // Use resolved entity text for entity resolution
82
+ confidence: 1.0,
83
+ slotType
84
+ };
85
+ // Extended properties for pronoun tracking
86
+ result.entityId = ref.entityId;
87
+ result.resolvedText = ref.text;
88
+ result.isPronoun = true;
89
+ return result;
90
+ }
91
+ // Multiple entities (e.g., "them" referring to multiple objects)
92
+ // Use extended type for items with entityId
93
+ const result = {
94
+ tokens: [startIndex],
95
+ text: pronoun,
96
+ confidence: 1.0,
97
+ slotType,
98
+ isList: true,
99
+ items: resolved.map(ref => ({
100
+ tokens: [startIndex],
101
+ text: ref.text,
102
+ entityId: ref.entityId
103
+ }))
104
+ };
105
+ // Mark as pronoun resolution
106
+ result.isPronoun = true;
107
+ return result;
108
+ }
109
+ /**
110
+ * Consume "all" and optionally "all but/except X"
111
+ */
112
+ consumeAllSlot(ctx, nextPatternToken, DEBUG) {
113
+ const { tokens, startIndex, slotType } = ctx;
114
+ const consumedIndices = [startIndex];
115
+ let currentIndex = startIndex + 1;
116
+ const excluded = [];
117
+ // Check for "but" or "except" after "all"
118
+ if (currentIndex < tokens.length) {
119
+ const nextWord = tokens[currentIndex].normalized;
120
+ if (nextWord === 'but' || nextWord === 'except') {
121
+ consumedIndices.push(currentIndex);
122
+ currentIndex++;
123
+ // Consume excluded entities (handles "X and Y" in exclusions)
124
+ const excludedResult = this.consumeExcludedEntities(ctx, currentIndex, nextPatternToken, DEBUG);
125
+ if (excludedResult) {
126
+ consumedIndices.push(...excludedResult.tokens);
127
+ excluded.push(...excludedResult.items);
128
+ }
129
+ }
130
+ }
131
+ if (DEBUG) {
132
+ console.log(`Consumed "all" slot with ${excluded.length} exclusions`);
133
+ }
134
+ return {
135
+ tokens: consumedIndices,
136
+ text: 'all',
137
+ confidence: 1.0,
138
+ slotType,
139
+ isAll: true,
140
+ excluded: excluded.length > 0 ? excluded : undefined
141
+ };
142
+ }
143
+ /**
144
+ * Consume entities after "but/except" with "and" support
145
+ */
146
+ consumeExcludedEntities(ctx, startIndex, nextPatternToken, DEBUG) {
147
+ const { tokens } = ctx;
148
+ const items = [];
149
+ const allTokens = [];
150
+ let currentIndex = startIndex;
151
+ while (currentIndex < tokens.length) {
152
+ // Check for pattern delimiter
153
+ if (nextPatternToken) {
154
+ const currentWord = tokens[currentIndex].normalized;
155
+ if (nextPatternToken.type === 'literal' && currentWord === nextPatternToken.value) {
156
+ break;
157
+ }
158
+ if (nextPatternToken.type === 'alternates' &&
159
+ nextPatternToken.alternates.includes(currentWord)) {
160
+ break;
161
+ }
162
+ }
163
+ // Skip "and" conjunctions
164
+ if (tokens[currentIndex].normalized === 'and') {
165
+ allTokens.push(currentIndex);
166
+ currentIndex++;
167
+ continue;
168
+ }
169
+ // Consume entity tokens (noun phrase)
170
+ const entityTokens = [];
171
+ const entityWords = [];
172
+ while (currentIndex < tokens.length) {
173
+ const word = tokens[currentIndex].normalized;
174
+ // Stop at "and", pattern delimiter, or other keywords
175
+ if (word === 'and')
176
+ break;
177
+ if (nextPatternToken?.type === 'literal' && word === nextPatternToken.value)
178
+ break;
179
+ if (nextPatternToken?.type === 'alternates' &&
180
+ nextPatternToken.alternates.includes(word))
181
+ break;
182
+ entityTokens.push(currentIndex);
183
+ entityWords.push(tokens[currentIndex].word);
184
+ currentIndex++;
185
+ }
186
+ if (entityTokens.length > 0) {
187
+ items.push({
188
+ tokens: entityTokens,
189
+ text: entityWords.join(' ')
190
+ });
191
+ allTokens.push(...entityTokens);
192
+ }
193
+ }
194
+ if (items.length === 0) {
195
+ return null;
196
+ }
197
+ return { tokens: allTokens, items };
198
+ }
199
+ /**
200
+ * Consume entity slot with "and" list detection
201
+ */
202
+ consumeEntityWithListDetection(ctx, DEBUG) {
203
+ const { slotName, tokens, startIndex, pattern, slotTokenIndex, rule, context, slotType } = ctx;
204
+ const nextPatternToken = pattern.tokens[slotTokenIndex + 1];
205
+ const items = [];
206
+ const allTokens = [];
207
+ const allWords = [];
208
+ let currentIndex = startIndex;
209
+ // When next pattern token is a slot (consecutive slots like "give :recipient :item"),
210
+ // we need to be conservative and find entity boundaries via constraint matching
211
+ const nextIsSlot = nextPatternToken?.type === 'slot';
212
+ // Main loop: consume entity, check for "and", repeat
213
+ while (currentIndex < tokens.length) {
214
+ // Check for pattern delimiter first
215
+ if (nextPatternToken) {
216
+ const currentWord = tokens[currentIndex].normalized;
217
+ if (nextPatternToken.type === 'literal' && currentWord === nextPatternToken.value) {
218
+ break;
219
+ }
220
+ if (nextPatternToken.type === 'alternates' &&
221
+ nextPatternToken.alternates.includes(currentWord)) {
222
+ break;
223
+ }
224
+ }
225
+ // Consume entity tokens (single noun phrase until "and" or delimiter)
226
+ const entityTokens = [];
227
+ const entityWords = [];
228
+ // For consecutive slots, use constraint-aware consumption
229
+ if (nextIsSlot && items.length === 0) {
230
+ // Try to find the shortest match that satisfies constraints
231
+ const slotConstraints = rule.slots.get(slotName);
232
+ let bestMatch = null;
233
+ // Try progressively longer phrases until we find a match or run out
234
+ for (let tryLength = 1; tryLength <= tokens.length - currentIndex; tryLength++) {
235
+ const tryTokens = [];
236
+ const tryWords = [];
237
+ for (let i = 0; i < tryLength && currentIndex + i < tokens.length; i++) {
238
+ const word = tokens[currentIndex + i].normalized;
239
+ // Stop at "and" - that would indicate a list
240
+ if (word === 'and')
241
+ break;
242
+ tryTokens.push(currentIndex + i);
243
+ tryWords.push(tokens[currentIndex + i].word);
244
+ }
245
+ if (tryTokens.length === 0)
246
+ break;
247
+ const tryText = tryWords.join(' ');
248
+ // Check if this matches constraints
249
+ if (slotConstraints && slotConstraints.constraints.length > 0 && context.world) {
250
+ const confidence = this.evaluateSlotConstraints(tryText, slotConstraints, context);
251
+ if (confidence > 0) {
252
+ bestMatch = { tokens: tryTokens, words: tryWords, confidence };
253
+ // Found a match - use it (greedy: first match wins)
254
+ break;
255
+ }
256
+ }
257
+ else {
258
+ // No constraints - take first word only for consecutive slots
259
+ bestMatch = { tokens: tryTokens, words: tryWords, confidence: 1.0 };
260
+ break;
261
+ }
262
+ }
263
+ if (bestMatch) {
264
+ entityTokens.push(...bestMatch.tokens);
265
+ entityWords.push(...bestMatch.words);
266
+ allTokens.push(...bestMatch.tokens);
267
+ allWords.push(...bestMatch.words);
268
+ currentIndex += bestMatch.tokens.length;
269
+ }
270
+ }
271
+ else {
272
+ // Standard consumption with delimiter detection
273
+ while (currentIndex < tokens.length) {
274
+ const word = tokens[currentIndex].normalized;
275
+ // Stop at "and" or pattern delimiter
276
+ if (word === 'and')
277
+ break;
278
+ if (nextPatternToken?.type === 'literal' && word === nextPatternToken.value)
279
+ break;
280
+ if (nextPatternToken?.type === 'alternates' &&
281
+ nextPatternToken.alternates.includes(word))
282
+ break;
283
+ entityTokens.push(currentIndex);
284
+ entityWords.push(tokens[currentIndex].word);
285
+ allTokens.push(currentIndex);
286
+ allWords.push(tokens[currentIndex].word);
287
+ currentIndex++;
288
+ }
289
+ }
290
+ if (entityTokens.length > 0) {
291
+ items.push({
292
+ tokens: entityTokens,
293
+ text: entityWords.join(' ')
294
+ });
295
+ }
296
+ // Check if next token is "and" - if so, consume it and continue
297
+ if (currentIndex < tokens.length && tokens[currentIndex].normalized === 'and') {
298
+ allTokens.push(currentIndex);
299
+ allWords.push(tokens[currentIndex].word);
300
+ currentIndex++;
301
+ // Continue the outer loop to consume more items
302
+ }
303
+ else {
304
+ // No more "and", we're done
305
+ break;
306
+ }
307
+ }
308
+ // Must consume at least one token
309
+ if (allTokens.length === 0) {
310
+ return null;
311
+ }
312
+ // Check constraints on each item
313
+ const slotConstraints = rule.slots.get(slotName);
314
+ let confidence = 1.0;
315
+ if (DEBUG) {
316
+ console.log(`Checking constraints for slot '${slotName}':`);
317
+ console.log(` slotConstraints exists: ${!!slotConstraints}`);
318
+ console.log(` constraints count: ${slotConstraints?.constraints?.length ?? 0}`);
319
+ console.log(` context.world exists: ${!!context.world}`);
320
+ }
321
+ if (slotConstraints && slotConstraints.constraints.length > 0 && context.world) {
322
+ // For lists, check constraints on each item
323
+ for (const item of items) {
324
+ const itemConfidence = this.evaluateSlotConstraints(item.text, slotConstraints, context);
325
+ confidence = Math.min(confidence, itemConfidence);
326
+ }
327
+ if (confidence === 0) {
328
+ if (DEBUG) {
329
+ console.log(`Failed to consume slot '${slotName}'`);
330
+ }
331
+ return null;
332
+ }
333
+ }
334
+ const result = {
335
+ tokens: allTokens,
336
+ text: allWords.join(' '),
337
+ confidence,
338
+ slotType
339
+ };
340
+ // If we have multiple items, mark as list
341
+ if (items.length > 1) {
342
+ result.isList = true;
343
+ result.items = items;
344
+ if (DEBUG) {
345
+ console.log(`Consumed list slot with ${items.length} items: ${items.map(i => i.text).join(', ')}`);
346
+ }
347
+ }
348
+ return result;
349
+ }
350
+ /**
351
+ * Evaluate slot constraints and return confidence
352
+ */
353
+ evaluateSlotConstraints(slotText, slotConstraints, context // GrammarContext
354
+ ) {
355
+ // For each constraint, check if any entities match
356
+ let hasMatchingEntity = false;
357
+ if (process.env.PARSER_DEBUG === 'true') {
358
+ console.log(`Evaluating constraints for slot text: "${slotText}"`);
359
+ }
360
+ for (const constraint of slotConstraints.constraints) {
361
+ if (typeof constraint === 'function') {
362
+ // Check if it's a ScopeConstraintBuilder (1 arg) vs FunctionConstraint (2 args)
363
+ if (constraint.length === 1) {
364
+ // ScopeConstraintBuilder
365
+ const scopeBuilder = new if_domain_1.ScopeBuilderImpl();
366
+ const scope = constraint(scopeBuilder);
367
+ const scopeConstraint = scope.build();
368
+ // Find entities matching the text within the scope
369
+ const matchingEntities = scope_evaluator_1.ScopeEvaluator.findEntitiesByName(slotText, scopeConstraint, context);
370
+ if (process.env.PARSER_DEBUG === 'true') {
371
+ console.log(`Found ${matchingEntities.length} matching entities for "${slotText}"`);
372
+ // Show scope details
373
+ console.log(` Scope base: ${scopeConstraint.base}, filters: ${scopeConstraint.filters.length}`);
374
+ // Show what entities are in scope before filtering
375
+ const allInScope = scope_evaluator_1.ScopeEvaluator.getEntitiesInScope({ ...scopeConstraint, filters: [] }, // Without filters
376
+ context);
377
+ console.log(` Entities in ${scopeConstraint.base} scope: ${allInScope.length}`);
378
+ for (const e of allInScope.slice(0, 5)) {
379
+ const identity = e.get?.('identity');
380
+ const name = identity?.name || e.id;
381
+ const enterable = e.enterable;
382
+ console.log(` - ${name} (enterable=${enterable})`);
383
+ }
384
+ if (allInScope.length > 5) {
385
+ console.log(` ... and ${allInScope.length - 5} more`);
386
+ }
387
+ }
388
+ if (matchingEntities.length > 0) {
389
+ hasMatchingEntity = true;
390
+ // Store matched entities in context for later resolution
391
+ const existingEntities = context.slots.get(slotText) || [];
392
+ context.slots.set(slotText, [...existingEntities, ...matchingEntities]);
393
+ }
394
+ }
395
+ else {
396
+ // FunctionConstraint - needs entity and context
397
+ // For now, we'll need to get candidate entities first
398
+ // This is a limitation - we'd need to refactor to support this properly
399
+ console.warn('FunctionConstraint in slot constraints not yet supported');
400
+ }
401
+ }
402
+ else {
403
+ // PropertyConstraint
404
+ // TODO: Handle property constraints
405
+ console.warn('PropertyConstraint in slot constraints not yet supported');
406
+ }
407
+ }
408
+ // Return confidence based on whether we found matching entities
409
+ return hasMatchingEntity ? 1.0 : 0.0;
410
+ }
411
+ }
412
+ exports.EntitySlotConsumer = EntitySlotConsumer;
413
+ //# sourceMappingURL=entity-slot-consumer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity-slot-consumer.js","sourceRoot":"","sources":["../../src/slot-consumers/entity-slot-consumer.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,kDAO4B;AAC5B,mDAA6G;AAC7G,wDAAoD;AACpD,wDAAmF;AAEnF;;;GAGG;AACH,MAAa,kBAAkB;IACpB,SAAS,GAAG,CAAC,oBAAQ,CAAC,MAAM,EAAE,oBAAQ,CAAC,UAAU,CAAC,CAAC;IAE5D,OAAO,CAAC,GAAwB;QAC9B,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,GAAG,CAAC;QAC7C,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,IAAI,KAAK,CAAC;QACjC,MAAM,gBAAgB,GAAG,IAAA,mCAAmB,EAAC,GAAG,CAAC,CAAC;QAElD,uCAAuC;QACvC,IAAI,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC;YAC/B,MAAM,SAAS,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,UAAU,CAAC;YAChD,IAAI,KAAK,EAAE,CAAC;gBACV,OAAO,CAAC,GAAG,CAAC,iCAAiC,UAAU,iBAAiB,MAAM,CAAC,UAAU,CAAC,EAAE,IAAI,wBAAwB,SAAS,GAAG,CAAC,CAAC;YACxI,CAAC;YAED,kCAAkC;YAClC,IAAI,IAAA,qCAAmB,EAAC,SAAS,CAAC,EAAE,CAAC;gBACnC,MAAM,aAAa,GAAG,IAAI,CAAC,iBAAiB,CAAC,GAAG,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;gBACpE,IAAI,aAAa,EAAE,CAAC;oBAClB,OAAO,aAAa,C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ChC,iBAAiB,GAAG,IAAI,CAAC;wBACzB,yDAAyD;wBACzD,MAAM,gBAAgB,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;wBAC3D,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,GAAG,gBAAgB,EAAE,GAAG,gBAAgB,CAAC,CAAC,CAAC;oBAC1E,CAAC;gBACH,CAAC;qBAAM,CAAC;oBACN,gDAAgD;oBAChD,sDAAsD;oBACtD,wEAAwE;oBACxE,OAAO,CAAC,IAAI,CAAC,0DAA0D,CAAC,CAAC;gBAC3E,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,qBAAqB;gBACrB,oCAAoC;gBACpC,OAAO,CAAC,IAAI,CAAC,0DAA0D,CAAC,CAAC;YAC3E,CAAC;QACH,CAAC;QAED,gEAAgE;QAChE,OAAO,iBAAiB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;IACvC,CAAC;CACF;AArdD,gDAqdC"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * @file Slot Consumer Registry
3
+ * @description Registry for slot consumption strategies (ADR-088)
4
+ */
5
+ import { SlotType, SlotMatch } from '@sharpee/if-domain';
6
+ import { SlotConsumer, SlotConsumerContext } from './slot-consumer';
7
+ export { SlotConsumer, SlotConsumerContext, getNextPatternToken, isPatternDelimiter } from './slot-consumer';
8
+ export { EntitySlotConsumer } from './entity-slot-consumer';
9
+ export { TextSlotConsumer } from './text-slot-consumer';
10
+ export { TypedSlotConsumer } from './typed-slot-consumer';
11
+ export { VocabularySlotConsumer } from './vocabulary-slot-consumer';
12
+ /**
13
+ * Registry for slot consumers
14
+ * Maps slot types to their consumer implementations
15
+ */
16
+ export declare class SlotConsumerRegistry {
17
+ private consumers;
18
+ /**
19
+ * Register a consumer for its declared slot types
20
+ */
21
+ register(consumer: SlotConsumer): void;
22
+ /**
23
+ * Check if a consumer is registered for a slot type
24
+ */
25
+ hasConsumer(slotType: SlotType): boolean;
26
+ /**
27
+ * Consume tokens for a slot type
28
+ * @param ctx The consumption context
29
+ * @returns SlotMatch if successful, null if no match
30
+ * @throws Error if no consumer registered for the slot type
31
+ */
32
+ consume(ctx: SlotConsumerContext): SlotMatch | null;
33
+ /**
34
+ * Get all registered slot types
35
+ */
36
+ getRegisteredTypes(): SlotType[];
37
+ }
38
+ /**
39
+ * Create a default registry with all standard consumers
40
+ * This will be populated as consumers are extracted
41
+ */
42
+ export declare function createDefaultRegistry(): SlotConsumerRegistry;
43
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/slot-consumers/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAMpE,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC7G,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAEpE;;;GAGG;AACH,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,SAAS,CAA0C;IAE3D;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,YAAY,GAAG,IAAI;IAMtC;;OAEG;IACH,WAAW,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO;IAIxC;;;;;OAKG;IACH,OAAO,CAAC,GAAG,EAAE,mBAAmB,GAAG,SAAS,GAAG,IAAI;IAQnD;;OAEG;IACH,kBAAkB,IAAI,QAAQ,EAAE;CAGjC;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,IAAI,oBAAoB,CAQ5D"}
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ /**
3
+ * @file Slot Consumer Registry
4
+ * @description Registry for slot consumption strategies (ADR-088)
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.SlotConsumerRegistry = exports.VocabularySlotConsumer = exports.TypedSlotConsumer = exports.TextSlotConsumer = exports.EntitySlotConsumer = exports.isPatternDelimiter = exports.getNextPatternToken = void 0;
8
+ exports.createDefaultRegistry = createDefaultRegistry;
9
+ const entity_slot_consumer_1 = require("./entity-slot-consumer");
10
+ const text_slot_consumer_1 = require("./text-slot-consumer");
11
+ const typed_slot_consumer_1 = require("./typed-slot-consumer");
12
+ const vocabulary_slot_consumer_1 = require("./vocabulary-slot-consumer");
13
+ var slot_consumer_1 = require("./slot-consumer");
14
+ Object.defineProperty(exports, "getNextPatternToken", { enumerable: true, get: function () { return slot_consumer_1.getNextPatternToken; } });
15
+ Object.defineProperty(exports, "isPatternDelimiter", { enumerable: true, get: function () { return slot_consumer_1.isPatternDelimiter; } });
16
+ var entity_slot_consumer_2 = require("./entity-slot-consumer");
17
+ Object.defineProperty(exports, "EntitySlotConsumer", { enumerable: true, get: function () { return entity_slot_consumer_2.EntitySlotConsumer; } });
18
+ var text_slot_consumer_2 = require("./text-slot-consumer");
19
+ Object.defineProperty(exports, "TextSlotConsumer", { enumerable: true, get: function () { return text_slot_consumer_2.TextSlotConsumer; } });
20
+ var typed_slot_consumer_2 = require("./typed-slot-consumer");
21
+ Object.defineProperty(exports, "TypedSlotConsumer", { enumerable: true, get: function () { return typed_slot_consumer_2.TypedSlotConsumer; } });
22
+ var vocabulary_slot_consumer_2 = require("./vocabulary-slot-consumer");
23
+ Object.defineProperty(exports, "VocabularySlotConsumer", { enumerable: true, get: function () { return vocabulary_slot_consumer_2.VocabularySlotConsumer; } });
24
+ /**
25
+ * Registry for slot consumers
26
+ * Maps slot types to their consumer implementations
27
+ */
28
+ class SlotConsumerRegistry {
29
+ consumers = new Map();
30
+ /**
31
+ * Register a consumer for its declared slot types
32
+ */
33
+ register(consumer) {
34
+ for (const type of consumer.slotTypes) {
35
+ this.consumers.set(type, consumer);
36
+ }
37
+ }
38
+ /**
39
+ * Check if a consumer is registered for a slot type
40
+ */
41
+ hasConsumer(slotType) {
42
+ return this.consumers.has(slotType);
43
+ }
44
+ /**
45
+ * Consume tokens for a slot type
46
+ * @param ctx The consumption context
47
+ * @returns SlotMatch if successful, null if no match
48
+ * @throws Error if no consumer registered for the slot type
49
+ */
50
+ consume(ctx) {
51
+ const consumer = this.consumers.get(ctx.slotType);
52
+ if (!consumer) {
53
+ throw new Error(`No consumer registered for slot type: ${ctx.slotType}`);
54
+ }
55
+ return consumer.consume(ctx);
56
+ }
57
+ /**
58
+ * Get all registered slot types
59
+ */
60
+ getRegisteredTypes() {
61
+ return Array.from(this.consumers.keys());
62
+ }
63
+ }
64
+ exports.SlotConsumerRegistry = SlotConsumerRegistry;
65
+ /**
66
+ * Create a default registry with all standard consumers
67
+ * This will be populated as consumers are extracted
68
+ */
69
+ function createDefaultRegistry() {
70
+ const registry = new SlotConsumerRegistry();
71
+ // ADR-088: All slot consumers extracted
72
+ registry.register(new entity_slot_consumer_1.EntitySlotConsumer());
73
+ registry.register(new text_slot_consumer_1.TextSlotConsumer());
74
+ registry.register(new typed_slot_consumer_1.TypedSlotConsumer());
75
+ registry.register(new vocabulary_slot_consumer_1.VocabularySlotConsumer());
76
+ return registry;
77
+ }
78
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/slot-consumers/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAgEH,sDAQC;AApED,iEAA4D;AAC5D,6DAAwD;AACxD,+DAA0D;AAC1D,yEAAoE;AAEpE,iDAA6G;AAAjE,oHAAA,mBAAmB,OAAA;AAAE,mHAAA,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