@sharpee/parser-en-us 0.9.66-beta → 0.9.69-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 (65) hide show
  1. package/direction-mappings.d.ts +24 -0
  2. package/direction-mappings.d.ts.map +1 -0
  3. package/direction-mappings.js +82 -0
  4. package/direction-mappings.js.map +1 -0
  5. package/english-grammar-engine.d.ts +85 -0
  6. package/english-grammar-engine.d.ts.map +1 -0
  7. package/english-grammar-engine.js +562 -0
  8. package/english-grammar-engine.js.map +1 -0
  9. package/english-parser.d.ts +184 -0
  10. package/english-parser.d.ts.map +1 -0
  11. package/english-parser.js +1268 -0
  12. package/english-parser.js.map +1 -0
  13. package/english-pattern-compiler.d.ts +29 -0
  14. package/english-pattern-compiler.d.ts.map +1 -0
  15. package/english-pattern-compiler.js +211 -0
  16. package/english-pattern-compiler.js.map +1 -0
  17. package/grammar.d.ts +19 -0
  18. package/grammar.d.ts.map +1 -0
  19. package/grammar.js +636 -0
  20. package/grammar.js.map +1 -0
  21. package/index.d.ts +24 -0
  22. package/index.d.ts.map +1 -0
  23. package/index.js +44 -0
  24. package/index.js.map +1 -0
  25. package/package.json +1 -13
  26. package/parse-failure.d.ts +59 -0
  27. package/parse-failure.d.ts.map +1 -0
  28. package/parse-failure.js +132 -0
  29. package/parse-failure.js.map +1 -0
  30. package/parser-types.d.ts +185 -0
  31. package/parser-types.d.ts.map +1 -0
  32. package/parser-types.js +134 -0
  33. package/parser-types.js.map +1 -0
  34. package/pronoun-context.d.ts +119 -0
  35. package/pronoun-context.d.ts.map +1 -0
  36. package/pronoun-context.js +249 -0
  37. package/pronoun-context.js.map +1 -0
  38. package/scope-evaluator.d.ts +58 -0
  39. package/scope-evaluator.d.ts.map +1 -0
  40. package/scope-evaluator.js +205 -0
  41. package/scope-evaluator.js.map +1 -0
  42. package/slot-consumers/entity-slot-consumer.d.ts +36 -0
  43. package/slot-consumers/entity-slot-consumer.d.ts.map +1 -0
  44. package/slot-consumers/entity-slot-consumer.js +413 -0
  45. package/slot-consumers/entity-slot-consumer.js.map +1 -0
  46. package/slot-consumers/index.d.ts +43 -0
  47. package/slot-consumers/index.d.ts.map +1 -0
  48. package/slot-consumers/index.js +78 -0
  49. package/slot-consumers/index.js.map +1 -0
  50. package/slot-consumers/slot-consumer.d.ts +61 -0
  51. package/slot-consumers/slot-consumer.d.ts.map +1 -0
  52. package/slot-consumers/slot-consumer.js +31 -0
  53. package/slot-consumers/slot-consumer.js.map +1 -0
  54. package/slot-consumers/text-slot-consumer.d.ts +33 -0
  55. package/slot-consumers/text-slot-consumer.d.ts.map +1 -0
  56. package/slot-consumers/text-slot-consumer.js +157 -0
  57. package/slot-consumers/text-slot-consumer.js.map +1 -0
  58. package/slot-consumers/typed-slot-consumer.d.ts +35 -0
  59. package/slot-consumers/typed-slot-consumer.d.ts.map +1 -0
  60. package/slot-consumers/typed-slot-consumer.js +151 -0
  61. package/slot-consumers/typed-slot-consumer.js.map +1 -0
  62. package/slot-consumers/vocabulary-slot-consumer.d.ts +42 -0
  63. package/slot-consumers/vocabulary-slot-consumer.d.ts.map +1 -0
  64. package/slot-consumers/vocabulary-slot-consumer.js +186 -0
  65. package/slot-consumers/vocabulary-slot-consumer.js.map +1 -0
@@ -0,0 +1,24 @@
1
+ /**
2
+ * English-specific direction mappings for the parser
3
+ * Maps English words and abbreviations to language-agnostic Direction constants
4
+ */
5
+ import { DirectionType } from "./src/index";
6
+ /**
7
+ * Map English direction words to Direction constants
8
+ */
9
+ export declare const DirectionWords: Record<string, DirectionType>;
10
+ /**
11
+ * Map English abbreviations to Direction constants
12
+ */
13
+ export declare const DirectionAbbreviations: Record<string, DirectionType>;
14
+ /**
15
+ * Parse an English direction string to a Direction constant
16
+ * Returns null if the string is not a recognized direction
17
+ */
18
+ export declare function parseDirection(input: string): DirectionType | null;
19
+ /**
20
+ * Get the English word for a Direction constant
21
+ * Used for display/output
22
+ */
23
+ export declare function getDirectionWord(direction: DirectionType): string;
24
+ //# sourceMappingURL=direction-mappings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"direction-mappings.d.ts","sourceRoot":"","sources":["../../../../../mnt/c/repotemp/sharpee/packages/parser-en-us/src/direction-mappings.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAa,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAEhE;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAexD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,sBAAsB,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAWhE,CAAC;AAEF;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI,CAgBlE;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,aAAa,GAAG,MAAM,CAajE"}
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ /**
3
+ * English-specific direction mappings for the parser
4
+ * Maps English words and abbreviations to language-agnostic Direction constants
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.DirectionAbbreviations = exports.DirectionWords = void 0;
8
+ exports.parseDirection = parseDirection;
9
+ exports.getDirectionWord = getDirectionWord;
10
+ const world_model_1 = require("./src/index.js");
11
+ /**
12
+ * Map English direction words to Direction constants
13
+ */
14
+ exports.DirectionWords = {
15
+ 'north': world_model_1.Direction.NORTH,
16
+ 'south': world_model_1.Direction.SOUTH,
17
+ 'east': world_model_1.Direction.EAST,
18
+ 'west': world_model_1.Direction.WEST,
19
+ 'northeast': world_model_1.Direction.NORTHEAST,
20
+ 'northwest': world_model_1.Direction.NORTHWEST,
21
+ 'southeast': world_model_1.Direction.SOUTHEAST,
22
+ 'southwest': world_model_1.Direction.SOUTHWEST,
23
+ 'up': world_model_1.Direction.UP,
24
+ 'down': world_model_1.Direction.DOWN,
25
+ 'in': world_model_1.Direction.IN,
26
+ 'inside': world_model_1.Direction.IN,
27
+ 'out': world_model_1.Direction.OUT,
28
+ 'outside': world_model_1.Direction.OUT
29
+ };
30
+ /**
31
+ * Map English abbreviations to Direction constants
32
+ */
33
+ exports.DirectionAbbreviations = {
34
+ 'n': world_model_1.Direction.NORTH,
35
+ 's': world_model_1.Direction.SOUTH,
36
+ 'e': world_model_1.Direction.EAST,
37
+ 'w': world_model_1.Direction.WEST,
38
+ 'ne': world_model_1.Direction.NORTHEAST,
39
+ 'nw': world_model_1.Direction.NORTHWEST,
40
+ 'se': world_model_1.Direction.SOUTHEAST,
41
+ 'sw': world_model_1.Direction.SOUTHWEST,
42
+ 'u': world_model_1.Direction.UP,
43
+ 'd': world_model_1.Direction.DOWN
44
+ };
45
+ /**
46
+ * Parse an English direction string to a Direction constant
47
+ * Returns null if the string is not a recognized direction
48
+ */
49
+ function parseDirection(input) {
50
+ if (!input)
51
+ return null;
52
+ const normalized = input.toLowerCase().trim();
53
+ // Check abbreviations first (more specific)
54
+ if (exports.DirectionAbbreviations[normalized]) {
55
+ return exports.DirectionAbbreviations[normalized];
56
+ }
57
+ // Then check full words
58
+ if (exports.DirectionWords[normalized]) {
59
+ return exports.DirectionWords[normalized];
60
+ }
61
+ return null;
62
+ }
63
+ /**
64
+ * Get the English word for a Direction constant
65
+ * Used for display/output
66
+ */
67
+ function getDirectionWord(direction) {
68
+ // Find the first matching English word for this direction
69
+ for (const [word, dir] of Object.entries(exports.DirectionWords)) {
70
+ if (dir === direction) {
71
+ // Prefer the primary forms (not 'inside'/'outside')
72
+ if (direction === world_model_1.Direction.IN && word === 'inside')
73
+ continue;
74
+ if (direction === world_model_1.Direction.OUT && word === 'outside')
75
+ continue;
76
+ return word;
77
+ }
78
+ }
79
+ // Fallback to lowercase version of constant
80
+ return direction.toLowerCase();
81
+ }
82
+ //# sourceMappingURL=direction-mappings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"direction-mappings.js","sourceRoot":"","sources":["../../../../../../../../mnt/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G,KAAK,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,CAAC;IAE9C,4CAA4C;IAC5C,IAAI,8BAAsB,CAAC,UAAU,CAAC,EAAE,CAAC;QACvC,OAAO,8BAAsB,CAAC,UAAU,CAAC,CAAC;IAC5C,CAAC;IAED,wBAAwB;IACxB,IAAI,sBAAc,CAAC,UAAU,CAAC,EAAE,CAAC;QAC/B,OAAO,sBAAc,CAAC,UAAU,CAAC,CAAC;IACpC,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;GAGG;AACH,SAAgB,gBAAgB,CAAC,SAAwB;IACvD,0DAA0D;IAC1D,KAAK,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,sBAAc,CAAC,EAAE,CAAC;QACzD,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;YACtB,oDAAoD;YACpD,IAAI,SAAS,KAAK,uBAAS,CAAC,EAAE,IAAI,IAAI,KAAK,QAAQ;gBAAE,SAAS;YAC9D,IAAI,SAAS,KAAK,uBAAS,CAAC,GAAG,IAAI,IAAI,KAAK,SAAS;gBAAE,SAAS;YAChE,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IAED,4CAA4C;IAC5C,OAAO,SAAS,CAAC,WAAW,EAAE,CAAC;AACjC,CAAC"}
@@ -0,0 +1,85 @@
1
+ /**
2
+ * @file English Grammar Engine
3
+ * @description English-specific implementation of grammar matching
4
+ */
5
+ import { GrammarEngine, GrammarContext, PatternMatch, GrammarMatchOptions, SlotMatch } from "./src/index";
6
+ import { Token } from "./src/index";
7
+ import { SlotConsumerRegistry } from './slot-consumers';
8
+ import type { PartialMatchFailure } from './parse-failure';
9
+ /**
10
+ * Result of attempting to match a rule - either success or failure with info
11
+ */
12
+ export type MatchAttemptResult = {
13
+ success: true;
14
+ match: PatternMatch;
15
+ } | {
16
+ success: false;
17
+ failure: PartialMatchFailure;
18
+ };
19
+ /**
20
+ * Extended match options with failure tracking
21
+ */
22
+ export interface ExtendedMatchOptions extends GrammarMatchOptions {
23
+ /** If true, collect partial match failures for error reporting */
24
+ trackFailures?: boolean;
25
+ }
26
+ /**
27
+ * Result of findMatches with optional failure information
28
+ */
29
+ export interface MatchResult {
30
+ matches: PatternMatch[];
31
+ failures?: PartialMatchFailure[];
32
+ }
33
+ /**
34
+ * English-specific grammar matching engine
35
+ */
36
+ export declare class EnglishGrammarEngine extends GrammarEngine {
37
+ private slotConsumerRegistry;
38
+ /** Last set of partial match failures (for error reporting) */
39
+ private lastFailures;
40
+ constructor(slotConsumerRegistry?: SlotConsumerRegistry);
41
+ /**
42
+ * Get the last set of partial match failures (for error reporting)
43
+ */
44
+ getLastFailures(): PartialMatchFailure[];
45
+ /**
46
+ * Find matching grammar rules for tokens
47
+ */
48
+ findMatches(tokens: Token[], context: GrammarContext, options?: GrammarMatchOptions): PatternMatch[];
49
+ /**
50
+ * Try to match a single rule against tokens
51
+ */
52
+ private tryMatchRule;
53
+ /**
54
+ * Try to match a single rule against tokens, returning failure info if no match
55
+ */
56
+ private tryMatchRuleWithFailure;
57
+ /**
58
+ * Build semantic properties from rule and matched tokens
59
+ */
60
+ private buildSemantics;
61
+ /**
62
+ * Consume tokens for a slot
63
+ */
64
+ private consumeSlot;
65
+ /**
66
+ * Extract typed value from a NUMBER slot match
67
+ */
68
+ static extractNumberValue(match: SlotMatch): number | null;
69
+ /**
70
+ * Extract typed value from an ORDINAL slot match
71
+ */
72
+ static extractOrdinalValue(match: SlotMatch): number | null;
73
+ /**
74
+ * Extract canonical direction from a DIRECTION slot match
75
+ */
76
+ static extractDirectionValue(match: SlotMatch): string | null;
77
+ /**
78
+ * Extract time components from a TIME slot match
79
+ */
80
+ static extractTimeValue(match: SlotMatch): {
81
+ hours: number;
82
+ minutes: number;
83
+ } | null;
84
+ }
85
+ //# sourceMappingURL=english-grammar-engine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"english-grammar-engine.d.ts","sourceRoot":"","s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