@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.
- package/dist/generators/gloss-generator.d.ts +18 -0
- package/dist/generators/learn-renderer.d.ts +13 -0
- package/dist/generators/sentence-generator.d.ts +34 -0
- package/dist/index.cjs +6116 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +441 -0
- package/dist/index.d.ts +55 -0
- package/dist/index.js +6056 -0
- package/dist/index.js.map +1 -0
- package/dist/profiles/ar.d.ts +2 -0
- package/dist/profiles/de.d.ts +2 -0
- package/dist/profiles/en.d.ts +2 -0
- package/dist/profiles/es.d.ts +2 -0
- package/dist/profiles/fr.d.ts +2 -0
- package/dist/profiles/index.d.ts +20 -0
- package/dist/profiles/ja.d.ts +2 -0
- package/dist/profiles/ko.d.ts +2 -0
- package/dist/profiles/pt.d.ts +2 -0
- package/dist/profiles/tr.d.ts +2 -0
- package/dist/profiles/zh.d.ts +2 -0
- package/dist/schemas/index.d.ts +31 -0
- package/dist/tokenizers/index.d.ts +23 -0
- package/dist/types.d.ts +266 -0
- package/package.json +63 -0
- package/src/__tests__/schemas.test.ts +145 -0
- package/src/__tests__/sentence-generation.test.ts +189 -0
- package/src/generators/gloss-generator.ts +145 -0
- package/src/generators/learn-renderer.ts +291 -0
- package/src/generators/sentence-generator.ts +501 -0
- package/src/index.ts +237 -0
- package/src/profiles/ar.ts +526 -0
- package/src/profiles/de.ts +481 -0
- package/src/profiles/en.ts +181 -0
- package/src/profiles/es.ts +829 -0
- package/src/profiles/fr.ts +466 -0
- package/src/profiles/index.ts +34 -0
- package/src/profiles/ja.ts +301 -0
- package/src/profiles/ko.ts +286 -0
- package/src/profiles/pt.ts +484 -0
- package/src/profiles/tr.ts +511 -0
- package/src/profiles/zh.ts +256 -0
- package/src/schemas/index.ts +576 -0
- package/src/tokenizers/index.ts +409 -0
- package/src/types.ts +321 -0
package/src/types.ts
ADDED
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Domain-Learn Types
|
|
3
|
+
*
|
|
4
|
+
* Types for the learning domain DSL, extending the framework with
|
|
5
|
+
* communicative functions, morphology tables, and sentence rendering.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// ─── Communicative Functions ────────────────────────────────────
|
|
9
|
+
|
|
10
|
+
/** The 7 communicative functions that exercises can target */
|
|
11
|
+
export type CommunicativeFunction =
|
|
12
|
+
| 'commanding' // imperative: "Add .active to #button"
|
|
13
|
+
| 'describing' // present: "The system adds .active to #button"
|
|
14
|
+
| 'narrating' // past: "The system added .active to #button"
|
|
15
|
+
| 'questioning' // question: "Did the system add .active to #button?"
|
|
16
|
+
| 'negating' // negative: "The system did not add .active to #button"
|
|
17
|
+
| 'planning' // future: "The system will add .active to #button"
|
|
18
|
+
| 'progressing'; // progressive: "The system is adding .active to #button"
|
|
19
|
+
|
|
20
|
+
export const ALL_FUNCTIONS: readonly CommunicativeFunction[] = [
|
|
21
|
+
'commanding',
|
|
22
|
+
'describing',
|
|
23
|
+
'narrating',
|
|
24
|
+
'questioning',
|
|
25
|
+
'negating',
|
|
26
|
+
'planning',
|
|
27
|
+
'progressing',
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
// ─── Core Verbs ─────────────────────────────────────────────────
|
|
31
|
+
|
|
32
|
+
/** The 15 core verbs in the learning domain */
|
|
33
|
+
export type CoreVerb =
|
|
34
|
+
| 'add'
|
|
35
|
+
| 'remove'
|
|
36
|
+
| 'toggle'
|
|
37
|
+
| 'put'
|
|
38
|
+
| 'set'
|
|
39
|
+
| 'show'
|
|
40
|
+
| 'hide'
|
|
41
|
+
| 'get'
|
|
42
|
+
| 'wait'
|
|
43
|
+
| 'fetch'
|
|
44
|
+
| 'send'
|
|
45
|
+
| 'go'
|
|
46
|
+
| 'increment'
|
|
47
|
+
| 'decrement'
|
|
48
|
+
| 'take';
|
|
49
|
+
|
|
50
|
+
export const ALL_VERBS: readonly CoreVerb[] = [
|
|
51
|
+
'add',
|
|
52
|
+
'remove',
|
|
53
|
+
'toggle',
|
|
54
|
+
'put',
|
|
55
|
+
'set',
|
|
56
|
+
'show',
|
|
57
|
+
'hide',
|
|
58
|
+
'get',
|
|
59
|
+
'wait',
|
|
60
|
+
'fetch',
|
|
61
|
+
'send',
|
|
62
|
+
'go',
|
|
63
|
+
'increment',
|
|
64
|
+
'decrement',
|
|
65
|
+
'take',
|
|
66
|
+
];
|
|
67
|
+
|
|
68
|
+
// ─── Semantic Roles ─────────────────────────────────────────────
|
|
69
|
+
|
|
70
|
+
export type SemanticRole =
|
|
71
|
+
| 'patient' // direct object: .active, #input
|
|
72
|
+
| 'destination' // allative: to #button
|
|
73
|
+
| 'source' // ablative: from #list
|
|
74
|
+
| 'instrument' // instrumental: with .class
|
|
75
|
+
| 'possessive' // genitive
|
|
76
|
+
| 'manner' // how
|
|
77
|
+
| 'style'; // in what manner
|
|
78
|
+
|
|
79
|
+
// ─── Verb Valence ───────────────────────────────────────────────
|
|
80
|
+
|
|
81
|
+
export type VerbValence = 'intransitive' | 'transitive' | 'ditransitive';
|
|
82
|
+
|
|
83
|
+
export interface CommandProfile {
|
|
84
|
+
verb: CoreVerb;
|
|
85
|
+
valence: VerbValence;
|
|
86
|
+
targetRole: SemanticRole | null;
|
|
87
|
+
hasPatient: boolean;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// ─── Sentence Frame ─────────────────────────────────────────────
|
|
91
|
+
|
|
92
|
+
export interface SentenceFrame {
|
|
93
|
+
function: CommunicativeFunction;
|
|
94
|
+
template: string;
|
|
95
|
+
verbForm: string;
|
|
96
|
+
example: string;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export interface LanguageFrames {
|
|
100
|
+
code: string;
|
|
101
|
+
wordOrder: 'SVO' | 'SOV' | 'VSO';
|
|
102
|
+
frames: SentenceFrame[];
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// ─── Rendered Output ────────────────────────────────────────────
|
|
106
|
+
|
|
107
|
+
export interface RenderedSentence {
|
|
108
|
+
language: string;
|
|
109
|
+
function: CommunicativeFunction;
|
|
110
|
+
sentence: string;
|
|
111
|
+
verbForm: string;
|
|
112
|
+
verbValue: string;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export interface InterlinearGloss {
|
|
116
|
+
tokens: string[];
|
|
117
|
+
roles: string[];
|
|
118
|
+
english: string[];
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// ─── Per-Language Form Interfaces ───────────────────────────────
|
|
122
|
+
|
|
123
|
+
export interface EnglishForms {
|
|
124
|
+
base: string;
|
|
125
|
+
thirdPerson: string;
|
|
126
|
+
past: string;
|
|
127
|
+
pastParticiple: string;
|
|
128
|
+
presentParticiple: string;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export interface JapaneseForms {
|
|
132
|
+
dictionary: string;
|
|
133
|
+
verbClass: 'godan' | 'ichidan' | 'suru' | 'kuru' | 'special';
|
|
134
|
+
stem: string;
|
|
135
|
+
masu: string;
|
|
136
|
+
mashita: string;
|
|
137
|
+
ta: string;
|
|
138
|
+
te: string;
|
|
139
|
+
nai: string;
|
|
140
|
+
masen: string;
|
|
141
|
+
potential: string;
|
|
142
|
+
volitional: string;
|
|
143
|
+
ba: string;
|
|
144
|
+
tara: string;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export interface SpanishPersonForms {
|
|
148
|
+
yo: string;
|
|
149
|
+
tu: string;
|
|
150
|
+
el: string;
|
|
151
|
+
nosotros: string;
|
|
152
|
+
vosotros: string;
|
|
153
|
+
ellos: string;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export interface SpanishForms {
|
|
157
|
+
infinitive: string;
|
|
158
|
+
verbClass: 'ar' | 'er' | 'ir';
|
|
159
|
+
irregular: boolean;
|
|
160
|
+
present: SpanishPersonForms;
|
|
161
|
+
preterite: SpanishPersonForms;
|
|
162
|
+
imperfect: SpanishPersonForms;
|
|
163
|
+
future: SpanishPersonForms;
|
|
164
|
+
imperative: { tu: string; usted: string; ustedes: string };
|
|
165
|
+
gerund: string;
|
|
166
|
+
pastParticiple: { ms: string; fs: string; mp: string; fp: string };
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export interface ArabicPersonForms {
|
|
170
|
+
howa: string;
|
|
171
|
+
hiya: string;
|
|
172
|
+
anta: string;
|
|
173
|
+
anti: string;
|
|
174
|
+
ana: string;
|
|
175
|
+
hum: string;
|
|
176
|
+
nahnu: string;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export interface ArabicForms {
|
|
180
|
+
root: string;
|
|
181
|
+
form: 'I' | 'II' | 'III' | 'IV' | 'V' | 'VI' | 'VII' | 'VIII' | 'X';
|
|
182
|
+
past: ArabicPersonForms;
|
|
183
|
+
present: ArabicPersonForms;
|
|
184
|
+
imperative: { ms: string; fs: string; mp: string };
|
|
185
|
+
activeParticiple: string;
|
|
186
|
+
passiveParticiple: string;
|
|
187
|
+
masdar: string;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export interface ChineseForms {
|
|
191
|
+
base: string;
|
|
192
|
+
pinyin: string;
|
|
193
|
+
patterns: {
|
|
194
|
+
completed: string;
|
|
195
|
+
experience: string;
|
|
196
|
+
progressive: string;
|
|
197
|
+
future: string;
|
|
198
|
+
negPresent: string;
|
|
199
|
+
negPast: string;
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export interface KoreanForms {
|
|
204
|
+
dictionary: string;
|
|
205
|
+
verbClass: 'hada' | 'native' | 'special';
|
|
206
|
+
stem: string;
|
|
207
|
+
hapnida: string;
|
|
208
|
+
haesseumnida: string;
|
|
209
|
+
haeyo: string;
|
|
210
|
+
haesseoyo: string;
|
|
211
|
+
imperative: string;
|
|
212
|
+
past: string;
|
|
213
|
+
negative: string;
|
|
214
|
+
progressive: string;
|
|
215
|
+
future: string;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export interface FrenchPersonForms {
|
|
219
|
+
je: string;
|
|
220
|
+
tu: string;
|
|
221
|
+
il: string;
|
|
222
|
+
nous: string;
|
|
223
|
+
vous: string;
|
|
224
|
+
ils: string;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
export interface FrenchForms {
|
|
228
|
+
infinitive: string;
|
|
229
|
+
imperative: { tu: string; vous: string };
|
|
230
|
+
present: FrenchPersonForms;
|
|
231
|
+
passeCompose: { il: string; je: string };
|
|
232
|
+
imparfait: { il: string };
|
|
233
|
+
futur: { il: string };
|
|
234
|
+
gerondif: string;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export interface TurkishForms {
|
|
238
|
+
dictionary: string;
|
|
239
|
+
imperative: { sen: string; siz: string };
|
|
240
|
+
present: {
|
|
241
|
+
ben: string;
|
|
242
|
+
sen: string;
|
|
243
|
+
o: string;
|
|
244
|
+
biz: string;
|
|
245
|
+
siz: string;
|
|
246
|
+
onlar: string;
|
|
247
|
+
};
|
|
248
|
+
past: { o: string; ben: string };
|
|
249
|
+
future: { o: string };
|
|
250
|
+
negative: { o: string };
|
|
251
|
+
progressive: { o: string };
|
|
252
|
+
gerund: string;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
export interface GermanPersonForms {
|
|
256
|
+
ich: string;
|
|
257
|
+
du: string;
|
|
258
|
+
er: string;
|
|
259
|
+
wir: string;
|
|
260
|
+
ihr: string;
|
|
261
|
+
sie: string;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
export interface GermanForms {
|
|
265
|
+
infinitive: string;
|
|
266
|
+
separablePrefix: string;
|
|
267
|
+
imperative: { du: string; Sie: string };
|
|
268
|
+
present: GermanPersonForms;
|
|
269
|
+
past: { ich: string; er: string };
|
|
270
|
+
perfect: { er: string };
|
|
271
|
+
future: { er: string };
|
|
272
|
+
presentParticiple: string;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
export interface PortuguesePersonForms {
|
|
276
|
+
eu: string;
|
|
277
|
+
voce: string;
|
|
278
|
+
ele: string;
|
|
279
|
+
nos: string;
|
|
280
|
+
voces: string;
|
|
281
|
+
eles: string;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
export interface PortugueseForms {
|
|
285
|
+
infinitive: string;
|
|
286
|
+
imperative: { voce: string; voces: string };
|
|
287
|
+
present: PortuguesePersonForms;
|
|
288
|
+
preterite: { ele: string; eu: string };
|
|
289
|
+
imperfect: { ele: string };
|
|
290
|
+
future: { ele: string };
|
|
291
|
+
gerund: string;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
// ─── Any Forms Union ────────────────────────────────────────────
|
|
295
|
+
|
|
296
|
+
export type AnyForms =
|
|
297
|
+
| EnglishForms
|
|
298
|
+
| JapaneseForms
|
|
299
|
+
| SpanishForms
|
|
300
|
+
| ArabicForms
|
|
301
|
+
| ChineseForms
|
|
302
|
+
| KoreanForms
|
|
303
|
+
| FrenchForms
|
|
304
|
+
| TurkishForms
|
|
305
|
+
| GermanForms
|
|
306
|
+
| PortugueseForms;
|
|
307
|
+
|
|
308
|
+
// ─── Extended Language Profile ──────────────────────────────────
|
|
309
|
+
|
|
310
|
+
import type { PatternGenLanguageProfile } from '@lokascript/framework';
|
|
311
|
+
|
|
312
|
+
export interface LearnLanguageProfile {
|
|
313
|
+
/** Base framework profile for pattern generation */
|
|
314
|
+
patternProfile: PatternGenLanguageProfile;
|
|
315
|
+
/** Morphology table: verb → conjugation forms */
|
|
316
|
+
morphologyTable: Record<string, AnyForms>;
|
|
317
|
+
/** Sentence frames per communicative function */
|
|
318
|
+
frames: LanguageFrames;
|
|
319
|
+
/** Default sentence subject */
|
|
320
|
+
defaultSubject: string;
|
|
321
|
+
}
|