@lokascript/domain-learn 2.1.0

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 (44) hide show
  1. package/dist/generators/gloss-generator.d.ts +18 -0
  2. package/dist/generators/learn-renderer.d.ts +13 -0
  3. package/dist/generators/sentence-generator.d.ts +34 -0
  4. package/dist/index.cjs +6116 -0
  5. package/dist/index.cjs.map +1 -0
  6. package/dist/index.d.cts +441 -0
  7. package/dist/index.d.ts +55 -0
  8. package/dist/index.js +6056 -0
  9. package/dist/index.js.map +1 -0
  10. package/dist/profiles/ar.d.ts +2 -0
  11. package/dist/profiles/de.d.ts +2 -0
  12. package/dist/profiles/en.d.ts +2 -0
  13. package/dist/profiles/es.d.ts +2 -0
  14. package/dist/profiles/fr.d.ts +2 -0
  15. package/dist/profiles/index.d.ts +20 -0
  16. package/dist/profiles/ja.d.ts +2 -0
  17. package/dist/profiles/ko.d.ts +2 -0
  18. package/dist/profiles/pt.d.ts +2 -0
  19. package/dist/profiles/tr.d.ts +2 -0
  20. package/dist/profiles/zh.d.ts +2 -0
  21. package/dist/schemas/index.d.ts +31 -0
  22. package/dist/tokenizers/index.d.ts +23 -0
  23. package/dist/types.d.ts +266 -0
  24. package/package.json +63 -0
  25. package/src/__tests__/schemas.test.ts +145 -0
  26. package/src/__tests__/sentence-generation.test.ts +189 -0
  27. package/src/generators/gloss-generator.ts +145 -0
  28. package/src/generators/learn-renderer.ts +291 -0
  29. package/src/generators/sentence-generator.ts +501 -0
  30. package/src/index.ts +237 -0
  31. package/src/profiles/ar.ts +526 -0
  32. package/src/profiles/de.ts +481 -0
  33. package/src/profiles/en.ts +181 -0
  34. package/src/profiles/es.ts +829 -0
  35. package/src/profiles/fr.ts +466 -0
  36. package/src/profiles/index.ts +34 -0
  37. package/src/profiles/ja.ts +301 -0
  38. package/src/profiles/ko.ts +286 -0
  39. package/src/profiles/pt.ts +484 -0
  40. package/src/profiles/tr.ts +511 -0
  41. package/src/profiles/zh.ts +256 -0
  42. package/src/schemas/index.ts +576 -0
  43. package/src/tokenizers/index.ts +409 -0
  44. package/src/types.ts +321 -0
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Gloss Generator — Interlinear Gloss for Learning
3
+ *
4
+ * Produces interlinear glosses from a SemanticNode, showing:
5
+ * tokens: target language tokens ["#buttonに", ".activeを", "追加して"]
6
+ * roles: grammatical labels ["DEST", "PAT", "VERB"]
7
+ * english: English gloss ["to #button", ".active", "add (imperative)"]
8
+ *
9
+ * Glosses help ESL students understand the grammatical function of each
10
+ * word/particle in context, and help code students understand the mapping
11
+ * between natural language and programming operations.
12
+ */
13
+ import type { SemanticNode } from '@lokascript/framework';
14
+ import type { InterlinearGloss, CommunicativeFunction } from '../types';
15
+ /**
16
+ * Generate an interlinear gloss for a SemanticNode.
17
+ */
18
+ export declare function generateGloss(node: SemanticNode, fn: CommunicativeFunction, language: string): InterlinearGloss | null;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Learn Renderer — SemanticNode → DSL text in any language
3
+ *
4
+ * Inverse of the parser: converts a parsed SemanticNode back to
5
+ * natural-language DSL text. Used for cross-language translation
6
+ * exercises and round-trip verification.
7
+ */
8
+ import type { SemanticNode } from '@lokascript/framework';
9
+ /**
10
+ * Render a SemanticNode as DSL text in the target language.
11
+ * Produces the commanding form (imperative) of the command.
12
+ */
13
+ export declare function renderLearn(node: SemanticNode, language: string): string;
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Learn Code Generator — The Inverted Generator
3
+ *
4
+ * Unlike domain-sql (natural language → SQL), this generator produces
5
+ * natural language sentences WITH morphology applied as its "compiled output".
6
+ *
7
+ * The standard CodeGenerator.generate() interface returns the commanding form
8
+ * in English. The extended generateForFunction() method produces sentences in
9
+ * any language × communicative function combination.
10
+ */
11
+ import type { SemanticNode, CodeGenerator } from '@lokascript/framework';
12
+ import type { CommunicativeFunction, RenderedSentence, LearnLanguageProfile } from '../types';
13
+ export interface ResolvedMarker {
14
+ marker: string;
15
+ position: 'before' | 'after';
16
+ }
17
+ export declare function resolveMarker(verb: string, role: string, language: string): ResolvedMarker;
18
+ export declare function attachMarker(value: string, resolved: ResolvedMarker): string;
19
+ export declare function registerProfile(code: string, profile: LearnLanguageProfile): void;
20
+ export declare function getProfile(code: string): LearnLanguageProfile | undefined;
21
+ /**
22
+ * Generate a sentence for a SemanticNode in a specific language and
23
+ * communicative function.
24
+ */
25
+ export declare function generateForFunction(node: SemanticNode, fn: CommunicativeFunction, language: string): RenderedSentence | null;
26
+ /**
27
+ * Standard CodeGenerator interface — returns the commanding form in English.
28
+ * This satisfies the framework's CodeGenerator contract.
29
+ */
30
+ export declare const learnCodeGenerator: CodeGenerator;
31
+ /** Render across all communicative functions for a language */
32
+ export declare function generateAllFunctions(node: SemanticNode, language: string): RenderedSentence[];
33
+ /** Render across all registered languages for a single function */
34
+ export declare function generateCrossLingual(node: SemanticNode, fn: CommunicativeFunction): RenderedSentence[];