@astl/engine 0.0.0 → 0.1.1

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 (98) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/LICENSE +202 -0
  3. package/README.md +41 -0
  4. package/dist/analyse.d.ts +68 -0
  5. package/dist/analyse.d.ts.map +1 -0
  6. package/dist/analyse.js +1179 -0
  7. package/dist/analyse.js.map +1 -0
  8. package/dist/checker.d.ts +19 -0
  9. package/dist/checker.d.ts.map +1 -0
  10. package/dist/checker.js +103 -0
  11. package/dist/checker.js.map +1 -0
  12. package/dist/compile.d.ts +16 -0
  13. package/dist/compile.d.ts.map +1 -0
  14. package/dist/compile.js +329 -0
  15. package/dist/compile.js.map +1 -0
  16. package/dist/conformance.d.ts +35 -0
  17. package/dist/conformance.d.ts.map +1 -0
  18. package/dist/conformance.js +101 -0
  19. package/dist/conformance.js.map +1 -0
  20. package/dist/engine.d.ts +13 -0
  21. package/dist/engine.d.ts.map +1 -0
  22. package/dist/engine.js +231 -0
  23. package/dist/engine.js.map +1 -0
  24. package/dist/grade.d.ts +9 -0
  25. package/dist/grade.d.ts.map +1 -0
  26. package/dist/grade.js +192 -0
  27. package/dist/grade.js.map +1 -0
  28. package/dist/guard.d.ts +45 -0
  29. package/dist/guard.d.ts.map +1 -0
  30. package/dist/guard.js +327 -0
  31. package/dist/guard.js.map +1 -0
  32. package/dist/help.d.ts +32 -0
  33. package/dist/help.d.ts.map +1 -0
  34. package/dist/help.js +120 -0
  35. package/dist/help.js.map +1 -0
  36. package/dist/html.d.ts +31 -0
  37. package/dist/html.d.ts.map +1 -0
  38. package/dist/html.js +246 -0
  39. package/dist/html.js.map +1 -0
  40. package/dist/ids.d.ts +35 -0
  41. package/dist/ids.d.ts.map +1 -0
  42. package/dist/ids.js +126 -0
  43. package/dist/ids.js.map +1 -0
  44. package/dist/index.d.ts +13 -0
  45. package/dist/index.d.ts.map +1 -0
  46. package/dist/index.js +10 -0
  47. package/dist/index.js.map +1 -0
  48. package/dist/kit/attributes.d.ts +6 -0
  49. package/dist/kit/attributes.d.ts.map +1 -0
  50. package/dist/kit/attributes.js +20 -0
  51. package/dist/kit/attributes.js.map +1 -0
  52. package/dist/kit/index.d.ts +43 -0
  53. package/dist/kit/index.d.ts.map +1 -0
  54. package/dist/kit/index.js +118 -0
  55. package/dist/kit/index.js.map +1 -0
  56. package/dist/limits.d.ts +17 -0
  57. package/dist/limits.d.ts.map +1 -0
  58. package/dist/limits.js +173 -0
  59. package/dist/limits.js.map +1 -0
  60. package/dist/messages/en.json +48 -0
  61. package/dist/messages/pl.json +48 -0
  62. package/dist/messages.d.ts +4 -0
  63. package/dist/messages.d.ts.map +1 -0
  64. package/dist/messages.js +9 -0
  65. package/dist/messages.js.map +1 -0
  66. package/dist/round.d.ts +3 -0
  67. package/dist/round.d.ts.map +1 -0
  68. package/dist/round.js +5 -0
  69. package/dist/round.js.map +1 -0
  70. package/dist/slot-kinds.d.ts +58 -0
  71. package/dist/slot-kinds.d.ts.map +1 -0
  72. package/dist/slot-kinds.js +151 -0
  73. package/dist/slot-kinds.js.map +1 -0
  74. package/dist/text.d.ts +23 -0
  75. package/dist/text.d.ts.map +1 -0
  76. package/dist/text.js +236 -0
  77. package/dist/text.js.map +1 -0
  78. package/package.json +51 -4
  79. package/src/analyse.ts +1396 -0
  80. package/src/checker.ts +132 -0
  81. package/src/compile.ts +394 -0
  82. package/src/conformance.ts +120 -0
  83. package/src/engine.ts +274 -0
  84. package/src/grade.ts +229 -0
  85. package/src/guard.ts +356 -0
  86. package/src/help.ts +141 -0
  87. package/src/html.ts +274 -0
  88. package/src/ids.ts +144 -0
  89. package/src/index.ts +12 -0
  90. package/src/kit/attributes.ts +21 -0
  91. package/src/kit/index.ts +140 -0
  92. package/src/limits.ts +153 -0
  93. package/src/messages/en.json +48 -0
  94. package/src/messages/pl.json +48 -0
  95. package/src/messages.ts +9 -0
  96. package/src/round.ts +4 -0
  97. package/src/slot-kinds.ts +212 -0
  98. package/src/text.ts +234 -0
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Built-in slot kinds. Keys are plain JSON and validated strictly, because they are stored and graded for years.
3
+ */
4
+ import { type NormalisationProfile, type SlotKind } from '@astl/core';
5
+ /** A NormalisationProfile as JSON data (an object type, so it fits JsonObject). */
6
+ export type ProfileData = {
7
+ readonly [K in keyof NormalisationProfile]: NormalisationProfile[K];
8
+ };
9
+ export type TextKey = {
10
+ /** Accepted answers as the author wrote them; the first one is the solution. */
11
+ readonly accept: readonly string[];
12
+ readonly profile: ProfileData;
13
+ readonly lang: string;
14
+ };
15
+ export type NumberKey = {
16
+ /** Accepted values; the first one is the solution. */
17
+ readonly values: readonly number[];
18
+ /** Accepted distance from a value. */
19
+ readonly tolerance: number;
20
+ readonly lang: string;
21
+ };
22
+ export type ChoiceKey = {
23
+ /** The correct value: an opaque option id, or a fixed public value such as `true` / `false`. */
24
+ readonly correct: string;
25
+ };
26
+ export type FlagKey = {
27
+ /** Whether the option should be selected. */
28
+ readonly correct: boolean;
29
+ };
30
+ export type LetterKey = {
31
+ /** One letter (one code point) in NFC capitals, as the cell shows it. */
32
+ readonly letter: string;
33
+ /** The language capitals are made in (Turkish i and İ). */
34
+ readonly lang: string;
35
+ };
36
+ /** True when `value` is a complete NormalisationProfile with known values only. */
37
+ export declare function isProfile(value: unknown): value is NormalisationProfile;
38
+ /** Typed text compared with the stored normalisation profile. */
39
+ export declare const textSlot: SlotKind<TextKey>;
40
+ /** A number in the content language's notation, within a tolerance. */
41
+ export declare const numberSlot: SlotKind<NumberKey>;
42
+ /** One picked value: an option's opaque id, or one of a fixed set of public values. */
43
+ export declare const choiceSlot: SlotKind<ChoiceKey>;
44
+ /** A selectable option (`'true'` when selected). Unselected flags are graded by the engine (see scoring). */
45
+ export declare const flagSlot: SlotKind<FlagKey>;
46
+ /**
47
+ * One letter in a square (a crossword cell): the answer in NFC capitals of the key's language, spaces around it
48
+ * ignored, equals the key's letter. Anything longer is wrong.
49
+ */
50
+ export declare const letterSlot: SlotKind<LetterKey>;
51
+ export type OpenKey = Record<string, never>;
52
+ /**
53
+ * An open answer (a long answer): stored with the attempt for a teacher, never graded, at most 2000 code points. Its
54
+ * key is empty: there is nothing to compare with.
55
+ */
56
+ export declare const openSlot: SlotKind<OpenKey>;
57
+ export declare const BUILT_IN_SLOT_KINDS: readonly SlotKind[];
58
+ //# sourceMappingURL=slot-kinds.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slot-kinds.d.ts","sourceRoot":"","sources":["../src/slot-kinds.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAGL,KAAK,oBAAoB,EAEzB,KAAK,QAAQ,EACd,MAAM,YAAY,CAAC;AAGpB,mFAAmF;AACnF,MAAM,MAAM,WAAW,GAAG;IAAE,QAAQ,EAAE,CAAC,IAAI,MAAM,oBAAoB,GAAG,oBAAoB,CAAC,CAAC,CAAC;CAAE,CAAC;AAElG,MAAM,MAAM,OAAO,GAAG;IACpB,gFAAgF;IAChF,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,sDAAsD;IACtD,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,sCAAsC;IACtC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,gGAAgG;IAChG,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB,6CAA6C;IAC7C,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,yEAAyE;IACzE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,2DAA2D;IAC3D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB,CAAC;AAWF,mFAAmF;AACnF,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,oBAAoB,CAKvE;AAeD,iEAAiE;AACjE,eAAO,MAAM,QAAQ,EAAE,QAAQ,CAAC,OAAO,CAmBtC,CAAC;AAEF,uEAAuE;AACvE,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAC,SAAS,CAuB1C,CAAC;AAEF,uFAAuF;AACvF,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAC,SAAS,CAY1C,CAAC;AAEF,6GAA6G;AAC7G,eAAO,MAAM,QAAQ,EAAE,QAAQ,CAAC,OAAO,CAYtC,CAAC;AAWF;;;GAGG;AACH,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAC,SAAS,CAiB1C,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AAE5C;;;GAGG;AACH,eAAO,MAAM,QAAQ,EAAE,QAAQ,CAAC,OAAO,CAStC,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,SAAS,QAAQ,EAOlD,CAAC"}
@@ -0,0 +1,151 @@
1
+ /**
2
+ * Built-in slot kinds. Keys are plain JSON and validated strictly, because they are stored and graded for years.
3
+ */
4
+ import { FLAG_SELECTED, OPEN_SLOT_KIND, } from '@astl/core';
5
+ import { formatNumber, normalise, parseNumber } from './text.js';
6
+ const PROFILE_VALUES = {
7
+ form: ['NFC', 'NFKC'],
8
+ space: ['strict', 'collapse'],
9
+ case: ['sensitive', 'insensitive'],
10
+ marks: ['strict', 'fold'],
11
+ punctuation: ['strict', 'ignore-edge'],
12
+ quotes: ['strict', 'fold'],
13
+ };
14
+ /** True when `value` is a complete NormalisationProfile with known values only. */
15
+ export function isProfile(value) {
16
+ if (!isPlainObject(value) || !hasExactly(value, Object.keys(PROFILE_VALUES)))
17
+ return false;
18
+ return Object.entries(PROFILE_VALUES).every(([name, allowed]) => allowed.includes(value[name]));
19
+ }
20
+ function isPlainObject(value) {
21
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
22
+ }
23
+ function hasExactly(value, names) {
24
+ const keys = Object.keys(value);
25
+ return keys.length === names.length && names.every((n) => Object.hasOwn(value, n));
26
+ }
27
+ function isNonEmptyArray(value) {
28
+ return Array.isArray(value) && value.length > 0;
29
+ }
30
+ /** Typed text compared with the stored normalisation profile. */
31
+ export const textSlot = {
32
+ kind: 'text',
33
+ selection: false,
34
+ isKey(key) {
35
+ return (hasExactly(key, ['accept', 'profile', 'lang']) &&
36
+ isNonEmptyArray(key.accept) &&
37
+ key.accept.every((a) => typeof a === 'string' && a !== '') &&
38
+ isProfile(key.profile) &&
39
+ typeof key.lang === 'string');
40
+ },
41
+ isCorrect(key, answer) {
42
+ const typed = normalise(answer, key.profile, key.lang);
43
+ return key.accept.some((a) => normalise(a, key.profile, key.lang) === typed);
44
+ },
45
+ solution(key) {
46
+ return key.accept[0] ?? '';
47
+ },
48
+ };
49
+ /** A number in the content language's notation, within a tolerance. */
50
+ export const numberSlot = {
51
+ kind: 'number',
52
+ selection: false,
53
+ isKey(key) {
54
+ return (hasExactly(key, ['values', 'tolerance', 'lang']) &&
55
+ isNonEmptyArray(key.values) &&
56
+ key.values.every((v) => typeof v === 'number' && Number.isFinite(v)) &&
57
+ typeof key.tolerance === 'number' &&
58
+ Number.isFinite(key.tolerance) &&
59
+ key.tolerance >= 0 &&
60
+ typeof key.lang === 'string');
61
+ },
62
+ isCorrect(key, answer) {
63
+ const value = parseNumber(answer, key.lang);
64
+ // The epsilon absorbs binary rounding, e.g. 0.1 + 0.2 against 0.3.
65
+ return value !== null && key.values.some((v) => Math.abs(value - v) <= key.tolerance + 1e-9);
66
+ },
67
+ solution(key) {
68
+ const first = key.values[0];
69
+ return first === undefined ? '' : formatNumber(first, key.lang);
70
+ },
71
+ };
72
+ /** One picked value: an option's opaque id, or one of a fixed set of public values. */
73
+ export const choiceSlot = {
74
+ kind: 'choice',
75
+ selection: false,
76
+ isKey(key) {
77
+ return hasExactly(key, ['correct']) && typeof key.correct === 'string' && key.correct !== '';
78
+ },
79
+ isCorrect(key, answer) {
80
+ return answer === key.correct;
81
+ },
82
+ solution(key) {
83
+ return key.correct;
84
+ },
85
+ };
86
+ /** A selectable option (`'true'` when selected). Unselected flags are graded by the engine (see scoring). */
87
+ export const flagSlot = {
88
+ kind: 'flag',
89
+ selection: true,
90
+ isKey(key) {
91
+ return hasExactly(key, ['correct']) && typeof key.correct === 'boolean';
92
+ },
93
+ isCorrect(key, answer) {
94
+ return (answer === FLAG_SELECTED) === key.correct;
95
+ },
96
+ solution(key) {
97
+ return key.correct ? FLAG_SELECTED : '';
98
+ },
99
+ };
100
+ function upperCase(value, lang) {
101
+ try {
102
+ return value.toLocaleUpperCase(lang);
103
+ }
104
+ catch {
105
+ // A malformed language tag in a stored key must not break grading.
106
+ return value.toUpperCase();
107
+ }
108
+ }
109
+ /**
110
+ * One letter in a square (a crossword cell): the answer in NFC capitals of the key's language, spaces around it
111
+ * ignored, equals the key's letter. Anything longer is wrong.
112
+ */
113
+ export const letterSlot = {
114
+ kind: 'letter',
115
+ selection: false,
116
+ isKey(key) {
117
+ return (hasExactly(key, ['letter', 'lang']) &&
118
+ typeof key.letter === 'string' &&
119
+ [...key.letter].length === 1 &&
120
+ typeof key.lang === 'string');
121
+ },
122
+ isCorrect(key, answer) {
123
+ return upperCase(answer.trim().normalize('NFC'), key.lang).normalize('NFC') === key.letter;
124
+ },
125
+ solution(key) {
126
+ return key.letter;
127
+ },
128
+ };
129
+ /**
130
+ * An open answer (a long answer): stored with the attempt for a teacher, never graded, at most 2000 code points. Its
131
+ * key is empty: there is nothing to compare with.
132
+ */
133
+ export const openSlot = {
134
+ kind: OPEN_SLOT_KIND,
135
+ selection: false,
136
+ graded: false,
137
+ isKey(key) {
138
+ return hasExactly(key, []);
139
+ },
140
+ isCorrect: () => false,
141
+ solution: () => '',
142
+ };
143
+ export const BUILT_IN_SLOT_KINDS = [
144
+ textSlot,
145
+ numberSlot,
146
+ choiceSlot,
147
+ flagSlot,
148
+ letterSlot,
149
+ openSlot,
150
+ ];
151
+ //# sourceMappingURL=slot-kinds.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slot-kinds.js","sourceRoot":"","sources":["../src/slot-kinds.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EACL,aAAa,EAGb,cAAc,GAEf,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAqCjE,MAAM,cAAc,GAAuF;IACzG,IAAI,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,CAAC,QAAQ,EAAE,UAAU,CAAC;IAC7B,IAAI,EAAE,CAAC,WAAW,EAAE,aAAa,CAAC;IAClC,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC;IACzB,WAAW,EAAE,CAAC,QAAQ,EAAE,aAAa,CAAC;IACtC,MAAM,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,mFAAmF;AACnF,MAAM,UAAU,SAAS,CAAC,KAAc;IACtC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAAE,OAAO,KAAK,CAAC;IAC3F,OAAO,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,EAAE,CAC7D,OAA8B,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CACtD,CAAC;AACJ,CAAC;AAED,SAAS,aAAa,C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ACR,UAAU;IACV,UAAU;IACV,QAAQ;IACR,UAAU;IACV,QAAQ;CACT,CAAC"}
package/dist/text.d.ts ADDED
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Text comparison and number parsing for grading. Pure functions: a stored key grades the same way on every runtime.
3
+ */
4
+ import type { NormalisationProfile } from '@astl/core';
5
+ /**
6
+ * Normalises typed text for comparison. Steps, each only when the profile asks for it: Unicode form, quote and
7
+ * dash folding, space collapsing, edge punctuation, case (locale-aware, so Turkish İ and I work) and diacritics.
8
+ * A late step can leave work for an earlier one (a dropped combining mark between two spaces, or after a final
9
+ * full stop), so the steps repeat until the text stops changing: the result is always a fixpoint.
10
+ */
11
+ export declare function normalise(text: string, profile: NormalisationProfile, lang: string): string;
12
+ /** True when the content language writes a decimal comma. */
13
+ export declare function usesDecimalComma(lang: string): boolean;
14
+ /**
15
+ * Parses a number as a student types it in the content language. Spaces may group digits; U+2212 is a minus sign.
16
+ * Decimal-comma languages accept `0,5`, `1.234,5` and a dot as the only separator: `1.234.567` is grouped, and a
17
+ * single `1.234` is grouped where the language groups with dots (German) but a decimal elsewhere (Polish). Other
18
+ * languages accept `0.5` and `1,234.5`. Returns null for anything else.
19
+ */
20
+ export declare function parseNumber(text: string, lang: string): number | null;
21
+ /** Formats a number for display in the content language: no grouping, decimal comma where the language uses one. */
22
+ export declare function formatNumber(value: number, lang: string): string;
23
+ //# sourceMappingURL=text.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../src/text.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAqCvD;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,oBAAoB,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAQ3F;AAuGD,6DAA6D;AAC7D,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEtD;AA0BD;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CA4BrE;AAQD,oHAAoH;AACpH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAIhE"}
package/dist/text.js ADDED
@@ -0,0 +1,236 @@
1
+ /**
2
+ * A global character class from code points. They stay numbers on purpose: formatters turn \u escapes into the raw
3
+ * characters, and several of these are invisible or look like a plain hyphen.
4
+ */
5
+ function anyOf(...codePoints) {
6
+ return new RegExp(`[${String.fromCodePoint(...codePoints)}]`, 'gu');
7
+ }
8
+ const SINGLE_QUOTES = anyOf(0x2018, 0x2019, 0x201a, 0x201b, 0x2032);
9
+ const DOUBLE_QUOTES = anyOf(0x201c, 0x201d, 0x201e, 0x201f, 0x2033, 0x00ab, 0x00bb);
10
+ const DASHES = anyOf(0x2012, 0x2013, 0x2014, 0x2212);
11
+ const ELLIPSIS = anyOf(0x2026);
12
+ const MINUS_SIGN = anyOf(0x2212);
13
+ const SPACES = /\s+/gu;
14
+ const PUNCTUATION = /^\p{P}$/u;
15
+ const WHITESPACE = /^\s$/u;
16
+ const MARKS = /\p{M}/gu;
17
+ /** Letters that NFD does not decompose but that `marks: fold` must treat as their base letters. */
18
+ const FOLDED_LETTERS = {
19
+ ł: 'l',
20
+ Ł: 'L',
21
+ ø: 'o',
22
+ Ø: 'O',
23
+ đ: 'd',
24
+ Đ: 'D',
25
+ ß: 'ss',
26
+ æ: 'ae',
27
+ Æ: 'AE',
28
+ œ: 'oe',
29
+ Œ: 'OE',
30
+ ı: 'i',
31
+ };
32
+ const FOLDED_LETTER = /[łŁøØđĐßæÆœŒı]/g;
33
+ /**
34
+ * Normalises typed text for comparison. Steps, each only when the profile asks for it: Unicode form, quote and
35
+ * dash folding, space collapsing, edge punctuation, case (locale-aware, so Turkish İ and I work) and diacritics.
36
+ * A late step can leave work for an earlier one (a dropped combining mark between two spaces, or after a final
37
+ * full stop), so the steps repeat until the text stops changing: the result is always a fixpoint.
38
+ */
39
+ export function normalise(text, profile, lang) {
40
+ let s = text;
41
+ for (let pass = 0; pass < MAX_PASSES; pass++) {
42
+ const next = normaliseOnce(s, profile, lang);
43
+ if (next === s)
44
+ break;
45
+ s = next;
46
+ }
47
+ return s;
48
+ }
49
+ /** Real text settles after one or two passes; the cap only bounds pathological input. */
50
+ const MAX_PASSES = 8;
51
+ function normaliseOnce(text, profile, lang) {
52
+ let s = text.normalize(profile.form);
53
+ if (profile.quotes === 'fold') {
54
+ s = s
55
+ .replace(SINGLE_QUOTES, "'")
56
+ .replace(DOUBLE_QUOTES, '"')
57
+ .replace(DASHES, '-')
58
+ .replace(ELLIPSIS, '...');
59
+ }
60
+ const collapse = profile.space === 'collapse';
61
+ if (collapse)
62
+ s = s.replace(SPACES, ' ').trim();
63
+ if (profile.punctuation === 'ignore-edge')
64
+ s = stripEdgePunctuation(s, collapse);
65
+ if (profile.case === 'insensitive')
66
+ s = lowerCase(s, lang);
67
+ if (profile.marks === 'fold') {
68
+ s = s
69
+ .normalize('NFD')
70
+ .replace(MARKS, '')
71
+ .replace(FOLDED_LETTER, (ch) => FOLDED_LETTERS[ch] ?? ch)
72
+ .normalize('NFC');
73
+ }
74
+ return s;
75
+ }
76
+ /**
77
+ * Drops punctuation at both ends (and, when trimming, the spaces it uncovers) until nothing changes. An answer made
78
+ * only of punctuation (`?`) is kept. One scan from each end: `/\p{P}+$/` would be quadratic on `a!!!...!a`.
79
+ */
80
+ function stripEdgePunctuation(value, trim) {
81
+ const strip = (codePoint) => {
82
+ const ch = String.fromCodePoint(codePoint);
83
+ return PUNCTUATION.test(ch) || (trim && WHITESPACE.test(ch));
84
+ };
85
+ let start = 0;
86
+ let end = value.length;
87
+ while (start < end) {
88
+ const codePoint = value.codePointAt(start) ?? 0;
89
+ if (!strip(codePoint))
90
+ break;
91
+ start += codePoint > 0xffff ? 2 : 1;
92
+ }
93
+ while (end > start) {
94
+ let last = end - 1;
95
+ const unit = value.charCodeAt(last);
96
+ if (unit >= 0xdc00 && unit <= 0xdfff && last > start) {
97
+ const high = value.charCodeAt(last - 1);
98
+ if (high >= 0xd800 && high <= 0xdbff)
99
+ last--;
100
+ }
101
+ if (!strip(value.codePointAt(last) ?? 0))
102
+ break;
103
+ end = last;
104
+ }
105
+ if (start === end)
106
+ return value;
107
+ return start === 0 && end === value.length ? value : value.slice(start, end);
108
+ }
109
+ function lowerCase(value, lang) {
110
+ try {
111
+ return value.toLocaleLowerCase(lang);
112
+ }
113
+ catch {
114
+ // A malformed language tag in a stored key must not break grading.
115
+ return value.toLowerCase();
116
+ }
117
+ }
118
+ /** Languages that write a decimal comma (`0,5`), by primary subtag. */
119
+ const COMMA_DECIMAL = new Set([
120
+ 'pl',
121
+ 'de',
122
+ 'fr',
123
+ 'es',
124
+ 'it',
125
+ 'pt',
126
+ 'ru',
127
+ 'uk',
128
+ 'cs',
129
+ 'sk',
130
+ 'sl',
131
+ 'hr',
132
+ 'sr',
133
+ 'bg',
134
+ 'ro',
135
+ 'hu',
136
+ 'lt',
137
+ 'lv',
138
+ 'et',
139
+ 'fi',
140
+ 'sv',
141
+ 'nb',
142
+ 'nn',
143
+ 'da',
144
+ 'nl',
145
+ 'tr',
146
+ 'el',
147
+ 'id',
148
+ 'vi',
149
+ 'be',
150
+ 'kk',
151
+ 'az',
152
+ ]);
153
+ /** True when the content language writes a decimal comma. */
154
+ export function usesDecimalComma(lang) {
155
+ return COMMA_DECIMAL.has(lang.toLowerCase().split('-')[0] ?? '');
156
+ }
157
+ /** Decimal-comma languages that group thousands with a dot (`1.234`), by primary subtag (CLDR). */
158
+ const DOT_GROUPING = new Set([
159
+ 'de',
160
+ 'es',
161
+ 'it',
162
+ 'pt',
163
+ 'sl',
164
+ 'hr',
165
+ 'sr',
166
+ 'ro',
167
+ 'da',
168
+ 'nl',
169
+ 'tr',
170
+ 'el',
171
+ 'id',
172
+ 'vi',
173
+ 'az',
174
+ ]);
175
+ const PLAIN_NUMBER = /^[+-]?(\d+(\.\d*)?|\.\d+)$/;
176
+ const COMMA_GROUPED = /^[+-]?\d{1,3}(,\d{3})+(\.\d*)?$/;
177
+ const DOT_GROUPED = /^[+-]?\d{1,3}(\.\d{3})+(,\d*)?$/;
178
+ const DOT_GROUPED_INTEGER = /^[+-]?\d{1,3}(\.\d{3})+$/;
179
+ /**
180
+ * Parses a number as a student types it in the content language. Spaces may group digits; U+2212 is a minus sign.
181
+ * Decimal-comma languages accept `0,5`, `1.234,5` and a dot as the only separator: `1.234.567` is grouped, and a
182
+ * single `1.234` is grouped where the language groups with dots (German) but a decimal elsewhere (Polish). Other
183
+ * languages accept `0.5` and `1,234.5`. Returns null for anything else.
184
+ */
185
+ export function parseNumber(text, lang) {
186
+ let s = text
187
+ .trim()
188
+ .replace(/(\d)\s+(?=\d)/gu, '$1')
189
+ .replace(MINUS_SIGN, '-');
190
+ const commas = count(s, ',');
191
+ const dots = count(s, '.');
192
+ const primary = lang.toLowerCase().split('-')[0] ?? '';
193
+ if (COMMA_DECIMAL.has(primary)) {
194
+ if (commas > 0 && dots > 0) {
195
+ if (commas > 1 || !DOT_GROUPED.test(s))
196
+ return null;
197
+ s = s.replace(/\./g, '').replace(',', '.');
198
+ }
199
+ else if (commas === 1) {
200
+ s = s.replace(',', '.');
201
+ }
202
+ else if (commas > 1) {
203
+ return null;
204
+ }
205
+ else if (dots > 0 && DOT_GROUPED_INTEGER.test(s) && (dots > 1 || DOT_GROUPING.has(primary))) {
206
+ s = s.replace(/\./g, '');
207
+ }
208
+ else if (dots > 1) {
209
+ return null;
210
+ }
211
+ }
212
+ else if (commas > 0) {
213
+ if (!COMMA_GROUPED.test(s))
214
+ return null;
215
+ s = s.replace(/,/g, '');
216
+ }
217
+ if (!PLAIN_NUMBER.test(s))
218
+ return null;
219
+ const value = Number(s);
220
+ return Number.isFinite(value) ? value : null;
221
+ }
222
+ function count(value, ch) {
223
+ let n = 0;
224
+ for (const c of value)
225
+ if (c === ch)
226
+ n++;
227
+ return n;
228
+ }
229
+ /** Formats a number for display in the content language: no grouping, decimal comma where the language uses one. */
230
+ export function formatNumber(value, lang) {
231
+ let s = String(value);
232
+ if (/e/i.test(s) && Math.abs(value) < 1e21)
233
+ s = value.toFixed(20).replace(/\.?0+$/, '');
234
+ return usesDecimalComma(lang) ? s.replace('.', ',') : s;
235
+ }
236
+ //# sourceMappingURL=text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text.js","sourceRoot":"","sources":["../src/text.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,SAAS,KAAK,CAAC,GAAG,UAAoB;IACpC,OAAO,IAAI,MAAM,CAAC,IAAI,MAAM,CAAC,aAAa,CAAC,GAAG,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;AACtE,CAAC;AAED,MAAM,aAAa,GAAG,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AACpE,MAAM,aAAa,GAAG,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AACpF,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AACrD,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;AAC/B,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;AACjC,MAAM,MAAM,GAAG,OAAO,CAAC;AACvB,MAAM,WAAW,GAAG,UAAU,CAAC;AAC/B,MAAM,UAAU,GAAG,OAAO,CAAC;AAC3B,MAAM,KAAK,GAAG,SAAS,CAAC;AAExB,mGAAmG;AACnG,MAAM,cAAc,GAAqC;IACvD,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAA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AC,IAAI,CAAC,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IACvC,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IACxB,OAAO,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AAC/C,CAAC;AAED,SAAS,KAAK,CAAC,KAAa,EAAE,EAAU;IACtC,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,KAAK,MAAM,CAAC,IAAI,KAAK;QAAE,IAAI,CAAC,KAAK,EAAE;YAAE,CAAC,EAAE,CAAC;IACzC,OAAO,CAAC,CAAC;AACX,CAAC;AAED,oHAAoH;AACpH,MAAM,UAAU,YAAY,CAAC,KAAa,EAAE,IAAY;IACtD,IAAI,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IACtB,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,IAAI;QAAE,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;IACxF,OAAO,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC1D,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,54 @@
1
1
  {
2
2
  "name": "@astl/engine",
3
- "version": "0.0.0",
4
- "description": "Placeholder for the trusted publishing setup. Use 0.1.0 or later.",
3
+ "version": "0.1.1",
4
+ "description": "Isomorphic Astrolabe engine: parse, sanitise, validate, compile (view + answer key + metadata) and grade.",
5
+ "keywords": [
6
+ "astrolabe",
7
+ "education",
8
+ "edtech",
9
+ "e-learning",
10
+ "interactive-exercises",
11
+ "quiz",
12
+ "assessment",
13
+ "grading",
14
+ "validation",
15
+ "isomorphic"
16
+ ],
5
17
  "license": "Apache-2.0",
6
- "repository": { "type": "git", "url": "git+https://github.com/starship1337/astrolabe.git" }
7
- }
18
+ "author": "The Astrolabe Authors",
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/starship1337/astrolabe.git",
22
+ "directory": "packages/engine"
23
+ },
24
+ "homepage": "https://astrolabe.starship.education",
25
+ "bugs": "https://github.com/starship1337/astrolabe/issues",
26
+ "type": "module",
27
+ "sideEffects": false,
28
+ "types": "./dist/index.d.ts",
29
+ "exports": {
30
+ ".": {
31
+ "@astl/source": "./src/index.ts",
32
+ "types": "./dist/index.d.ts",
33
+ "default": "./dist/index.js"
34
+ },
35
+ "./package.json": "./package.json"
36
+ },
37
+ "files": [
38
+ "dist",
39
+ "src",
40
+ "CHANGELOG.md",
41
+ "!src/**/*.test.ts",
42
+ "!src/**/testing"
43
+ ],
44
+ "engines": {
45
+ "node": ">=22.12"
46
+ },
47
+ "publishConfig": {
48
+ "access": "public"
49
+ },
50
+ "dependencies": {
51
+ "@astl/core": "0.1.1",
52
+ "parse5": "8.0.1"
53
+ }
54
+ }