@keymanapp/kmc-model 17.0.85-alpha → 17.0.87-alpha

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 (144) hide show
  1. package/package.json +6 -5
  2. package/.nyc_output/coverage-10524-1681239236645-0.json +0 -1
  3. package/Makefile +0 -38
  4. package/build/cjs-src/lexical-model-compiler.cjs +0 -152688
  5. package/build/test/helpers/index.d.ts +0 -69
  6. package/build/test/helpers/index.d.ts.map +0 -1
  7. package/build/test/helpers/index.js +0 -160
  8. package/build/test/helpers/index.js.map +0 -1
  9. package/build/test/test-compile-model-with-pseudoclosure.d.ts +0 -2
  10. package/build/test/test-compile-model-with-pseudoclosure.d.ts.map +0 -1
  11. package/build/test/test-compile-model-with-pseudoclosure.js +0 -200
  12. package/build/test/test-compile-model-with-pseudoclosure.js.map +0 -1
  13. package/build/test/test-compile-model.d.ts +0 -2
  14. package/build/test/test-compile-model.d.ts.map +0 -1
  15. package/build/test/test-compile-model.js +0 -30
  16. package/build/test/test-compile-model.js.map +0 -1
  17. package/build/test/test-compile-trie.d.ts +0 -2
  18. package/build/test/test-compile-trie.d.ts.map +0 -1
  19. package/build/test/test-compile-trie.js +0 -125
  20. package/build/test/test-compile-trie.js.map +0 -1
  21. package/build/test/test-default-apply-case.d.ts +0 -2
  22. package/build/test/test-default-apply-case.d.ts.map +0 -1
  23. package/build/test/test-default-apply-case.js +0 -105
  24. package/build/test/test-default-apply-case.js.map +0 -1
  25. package/build/test/test-default-search-term-to-key.d.ts +0 -2
  26. package/build/test/test-default-search-term-to-key.d.ts.map +0 -1
  27. package/build/test/test-default-search-term-to-key.js +0 -148
  28. package/build/test/test-default-search-term-to-key.js.map +0 -1
  29. package/build/test/test-error-logger.d.ts +0 -2
  30. package/build/test/test-error-logger.d.ts.map +0 -1
  31. package/build/test/test-error-logger.js +0 -26
  32. package/build/test/test-error-logger.js.map +0 -1
  33. package/build/test/test-join-word-breaker.d.ts +0 -2
  34. package/build/test/test-join-word-breaker.d.ts.map +0 -1
  35. package/build/test/test-join-word-breaker.js +0 -84
  36. package/build/test/test-join-word-breaker.js.map +0 -1
  37. package/build/test/test-model-definitions.d.ts +0 -2
  38. package/build/test/test-model-definitions.d.ts.map +0 -1
  39. package/build/test/test-model-definitions.js +0 -165
  40. package/build/test/test-model-definitions.js.map +0 -1
  41. package/build/test/test-override-script-defaults.d.ts +0 -2
  42. package/build/test/test-override-script-defaults.d.ts.map +0 -1
  43. package/build/test/test-override-script-defaults.js +0 -28
  44. package/build/test/test-override-script-defaults.js.map +0 -1
  45. package/build/test/test-parse-wordlist.d.ts +0 -2
  46. package/build/test/test-parse-wordlist.d.ts.map +0 -1
  47. package/build/test/test-parse-wordlist.js +0 -110
  48. package/build/test/test-parse-wordlist.js.map +0 -1
  49. package/build/test/test-punctuation.d.ts +0 -2
  50. package/build/test/test-punctuation.d.ts.map +0 -1
  51. package/build/test/test-punctuation.js +0 -31
  52. package/build/test/test-punctuation.js.map +0 -1
  53. package/build/test/tsconfig.tsbuildinfo +0 -1
  54. package/build/test/wordbreakers/data.d.ts +0 -35
  55. package/build/test/wordbreakers/data.d.ts.map +0 -1
  56. package/build/test/wordbreakers/data.js +0 -1778
  57. package/build/test/wordbreakers/data.js.map +0 -1
  58. package/build/test/wordbreakers/default-wordbreaker-esm.d.ts +0 -10
  59. package/build/test/wordbreakers/default-wordbreaker-esm.d.ts.map +0 -1
  60. package/build/test/wordbreakers/default-wordbreaker-esm.js +0 -354
  61. package/build/test/wordbreakers/default-wordbreaker-esm.js.map +0 -1
  62. package/build/tsconfig.tsbuildinfo +0 -1
  63. package/build.sh +0 -73
  64. package/coverage/lcov-report/base.css +0 -224
  65. package/coverage/lcov-report/block-navigation.js +0 -87
  66. package/coverage/lcov-report/favicon.png +0 -0
  67. package/coverage/lcov-report/index.html +0 -161
  68. package/coverage/lcov-report/prettify.css +0 -1
  69. package/coverage/lcov-report/prettify.js +0 -2
  70. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  71. package/coverage/lcov-report/sorter.js +0 -196
  72. package/coverage/lcov-report/src/build-trie.ts.html +0 -1618
  73. package/coverage/lcov-report/src/index.html +0 -221
  74. package/coverage/lcov-report/src/join-word-breaker-decorator.ts.html +0 -487
  75. package/coverage/lcov-report/src/lexical-model-compiler.ts.html +0 -622
  76. package/coverage/lcov-report/src/main.ts.html +0 -271
  77. package/coverage/lcov-report/src/model-compiler-errors.ts.html +0 -691
  78. package/coverage/lcov-report/src/model-defaults.ts.html +0 -415
  79. package/coverage/lcov-report/src/model-definitions.ts.html +0 -748
  80. package/coverage/lcov-report/src/script-overrides-decorator.ts.html +0 -310
  81. package/coverage/lcov-report/test/helpers/index.html +0 -116
  82. package/coverage/lcov-report/test/helpers/index.ts.html +0 -646
  83. package/coverage/lcov-report/test/index.html +0 -266
  84. package/coverage/lcov-report/test/test-compile-model-with-pseudoclosure.ts.html +0 -802
  85. package/coverage/lcov-report/test/test-compile-model.ts.html +0 -187
  86. package/coverage/lcov-report/test/test-compile-trie.ts.html +0 -541
  87. package/coverage/lcov-report/test/test-default-apply-case.ts.html +0 -466
  88. package/coverage/lcov-report/test/test-default-search-term-to-key.ts.html +0 -628
  89. package/coverage/lcov-report/test/test-error-logger.ts.html +0 -196
  90. package/coverage/lcov-report/test/test-join-word-breaker.ts.html +0 -376
  91. package/coverage/lcov-report/test/test-model-definitions.ts.html +0 -676
  92. package/coverage/lcov-report/test/test-override-script-defaults.ts.html +0 -184
  93. package/coverage/lcov-report/test/test-parse-wordlist.ts.html +0 -466
  94. package/coverage/lcov-report/test/test-punctuation.ts.html +0 -190
  95. package/coverage/lcov-report/test/wordbreakers/data.ts.html +0 -5413
  96. package/coverage/lcov-report/test/wordbreakers/default-wordbreaker-esm.ts.html +0 -1234
  97. package/coverage/lcov-report/test/wordbreakers/index.html +0 -131
  98. package/coverage/lcov.info +0 -5969
  99. package/src/build-trie.ts +0 -511
  100. package/src/join-word-breaker-decorator.ts +0 -134
  101. package/src/lexical-model-compiler.ts +0 -179
  102. package/src/lexical-model.ts +0 -150
  103. package/src/main.ts +0 -62
  104. package/src/model-compiler-errors.ts +0 -203
  105. package/src/model-defaults.ts +0 -111
  106. package/src/model-definitions.ts +0 -222
  107. package/src/script-overrides-decorator.ts +0 -75
  108. package/test/README.md +0 -15
  109. package/test/fixtures/example.qaa.joinwordbreaker/example.qaa.joinwordbreaker.model.ts +0 -10
  110. package/test/fixtures/example.qaa.joinwordbreaker/wordlist.tsv +0 -3
  111. package/test/fixtures/example.qaa.scriptusesspaces/example.qaa.scriptusesspaces.model.ts +0 -10
  112. package/test/fixtures/example.qaa.scriptusesspaces/wordlist.tsv +0 -8
  113. package/test/fixtures/example.qaa.sencoten/example.qaa.sencoten.model.kmp.json +0 -45
  114. package/test/fixtures/example.qaa.sencoten/example.qaa.sencoten.model.kps +0 -35
  115. package/test/fixtures/example.qaa.sencoten/example.qaa.sencoten.model.ts +0 -6
  116. package/test/fixtures/example.qaa.sencoten/wordlist.tsv +0 -10
  117. package/test/fixtures/example.qaa.smp/example.qaa.smp.model.ts +0 -6
  118. package/test/fixtures/example.qaa.smp/wordlist.tsv +0 -5
  119. package/test/fixtures/example.qaa.trivial/example.qaa.trivial.model.ts +0 -5
  120. package/test/fixtures/example.qaa.trivial/wordlist.tsv +0 -3
  121. package/test/fixtures/example.qaa.utf16be/example.qaa.utf16be.model.ts +0 -5
  122. package/test/fixtures/example.qaa.utf16be/wordlist.txt +0 -0
  123. package/test/fixtures/example.qaa.utf16le/example.qaa.utf16le.model.ts +0 -5
  124. package/test/fixtures/example.qaa.utf16le/wordlist.txt +0 -0
  125. package/test/fixtures/example.qaa.wordbreaker/example.qaa.wordbreaker.model.ts +0 -9
  126. package/test/fixtures/example.qaa.wordbreaker/wordlist.tsv +0 -3
  127. package/test/helpers/index.ts +0 -187
  128. package/test/test-compile-model-with-pseudoclosure.ts +0 -239
  129. package/test/test-compile-model.ts +0 -34
  130. package/test/test-compile-trie.ts +0 -152
  131. package/test/test-default-apply-case.ts +0 -128
  132. package/test/test-default-search-term-to-key.ts +0 -181
  133. package/test/test-error-logger.ts +0 -38
  134. package/test/test-join-word-breaker.ts +0 -97
  135. package/test/test-model-definitions.ts +0 -198
  136. package/test/test-override-script-defaults.ts +0 -33
  137. package/test/test-parse-wordlist.ts +0 -127
  138. package/test/test-punctuation.ts +0 -35
  139. package/test/tsconfig.json +0 -22
  140. package/test/wordbreakers/README.md +0 -3
  141. package/test/wordbreakers/data.ts +0 -1776
  142. package/test/wordbreakers/default-wordbreaker-esm.ts +0 -383
  143. package/tools/create-override-script-regexp.ts +0 -145
  144. package/tsconfig.json +0 -17
@@ -1,127 +0,0 @@
1
- import {parseWordListFromContents, parseWordListFromFilename, WordList} from '../src/build-trie.js';
2
- import {assert} from 'chai';
3
- import 'mocha';
4
- import { makePathToFixture, LogHoarder } from './helpers/index.js';
5
- import { KeymanCompilerError } from '../src/model-compiler-errors.js';
6
-
7
- const BOM = '\ufeff';
8
- const SENCOTEN_WORDLIST = {
9
- 'TŦE': 13644,
10
- 'E': 9134,
11
- 'SEN': 4816,
12
- 'Ȼ': 3479,
13
- 'SW̱': 2621,
14
- 'NIȽ': 2314,
15
- 'U¸': 2298,
16
- 'I¸': 1988,
17
- 'ȻSE': 1925,
18
- 'I': 1884
19
- };
20
-
21
- describe('parsing a word list', function () {
22
- beforeEach(function () {
23
- this.logHoarder = (new LogHoarder).install()
24
- })
25
-
26
- afterEach(function () {
27
- this.logHoarder.uninstall();
28
- delete this.logHoarder;
29
- })
30
-
31
- it('should remove the UTF-8 byte order mark from files', function () {
32
- let word = 'hello';
33
- let count = 1;
34
- let expected: WordList = {};
35
- expected[word] = count;
36
-
37
- let file = `# this is a comment\n${word}\t${count}`;
38
- let withoutBOM: WordList = {};
39
- parseWordListFromContents(withoutBOM, file);
40
- assert.deepEqual(withoutBOM, expected, "expected regular file to parse properly");
41
- assert.isFalse(this.logHoarder.hasSeenWarnings());
42
-
43
- let withBOM: WordList = {};
44
- parseWordListFromContents(withBOM, `${BOM}${file}`)
45
- assert.deepEqual(withBOM, expected, "expected BOM to be ignored");
46
- assert.isFalse(this.logHoarder.hasSeenWarnings());
47
- });
48
-
49
- it('should read word lists in UTF-8', function () {
50
- // N.B.: this is the format exported by Google Drive when selecting "TSV".
51
- const filename = makePathToFixture('example.qaa.sencoten', 'wordlist.tsv');
52
- let wordlist: WordList = {};
53
- parseWordListFromFilename(wordlist, filename);
54
-
55
- assert.deepEqual(wordlist, SENCOTEN_WORDLIST);
56
- assert.isFalse(this.logHoarder.hasSeenWarnings());
57
- });
58
-
59
- it('should read word lists in UTF-16 little-endian (with BOM)', function () {
60
- // N.B.: this is the format exported by MS Excel when selecting
61
- // "UTF-16" text (tested on Excel for macOS).
62
- const filename = makePathToFixture('example.qaa.utf16le', 'wordlist.txt');
63
- let wordlist: WordList = {};
64
- parseWordListFromFilename(wordlist, filename);
65
-
66
- assert.deepEqual(wordlist, SENCOTEN_WORDLIST);
67
- assert.isFalse(this.logHoarder.hasSeenWarnings());
68
- });
69
-
70
- it('should NOT read word lists in UTF-16 big-endian (with BOM)', function () {
71
- // N.B.: Does anything output this format...?
72
- const filename = makePathToFixture('example.qaa.utf16be', 'wordlist.txt');
73
- let wordlist: WordList = {};
74
- assert.throws(() => {
75
- parseWordListFromFilename(wordlist, filename);
76
- }, 'UTF-16BE is unsupported');
77
- });
78
-
79
- it('should merge duplicate entries in a wordlist', function () {
80
- // Tests that we merge NFC+NFD entries and identical entries, trimming whitespace
81
- // Note building the wordlist from an array to make clear that we have unnormalised inputs
82
- const words = [
83
- 'hello', //1
84
- 'hello\u0301', //2, NFD helló
85
- 'hell\u00f3', //3, NFC helló
86
- ' hello ', //4, expect to trim whitespace
87
- 'hello']; //5
88
-
89
- const expected: WordList = {
90
- 'hello': 10, /* 1+4+5 trimmed and identical */
91
- 'hell\u00f3': 5, /* 2+3 normalised to NFC */
92
- };
93
-
94
- // Build a wordlist from the array
95
- let file = `# this is a comment\n`;
96
- for(let i = 0; i < words.length; i++) {
97
- file += `${words[i]}\t${i+1}\n`;
98
- }
99
- let repeatedWords: WordList = {};
100
- parseWordListFromContents(repeatedWords, file);
101
-
102
- assert.deepEqual(repeatedWords, expected);
103
-
104
- assert.isTrue(this.logHoarder.hasSeenWarnings());
105
- // hello has been seen multiple times:
106
- assert.isTrue(this.logHoarder.hasSeenCode(KeymanCompilerError.CWARN_DuplicateWordInSameFile));
107
- // helló and hello + U+0301 have both been seen:
108
- assert.isTrue(this.logHoarder.hasSeenCode(KeymanCompilerError.CWARN_MixedNormalizationForms));
109
-
110
- // Let's parse another file:
111
-
112
- this.logHoarder.clear();
113
- // Now, parse a DIFFERENT file, but with an NFD entry.
114
- parseWordListFromContents(repeatedWords, "hello\u0301\t5\n");
115
- assert.isTrue(this.logHoarder.hasSeenWarnings())
116
- // hello + U+0301 (NFD) has been seen, but...
117
- assert.isTrue(this.logHoarder.hasSeenCode(KeymanCompilerError.CWARN_MixedNormalizationForms));
118
- // BUT! We have not seen a duplicate **within the same file**
119
- assert.isFalse(this.logHoarder.hasSeenCode(KeymanCompilerError.CWARN_DuplicateWordInSameFile));
120
-
121
- assert.deepEqual(repeatedWords, {
122
- hello: expected['hello'],
123
- // should have seen more of this entry:
124
- "hell\u00f3": expected["hell\u00f3"] + 5,
125
- });
126
- });
127
- });
@@ -1,35 +0,0 @@
1
- import LexicalModelCompiler from '../src/lexical-model-compiler.js';
2
- import {assert} from 'chai';
3
- import 'mocha';
4
-
5
- import { makePathToFixture, compileModelSourceCode } from './helpers/index.js';
6
-
7
- describe('LexicalModelCompiler', function () {
8
- describe('specifying punctuation', function () {
9
- const MODEL_ID = 'example.qaa.trivial';
10
- const PATH = makePathToFixture(MODEL_ID);
11
-
12
- it('should compile punctuation into the generated code', function () {
13
- let compiler = new LexicalModelCompiler;
14
- let code = compiler.generateLexicalModelCode(MODEL_ID, {
15
- format: 'trie-1.0',
16
- sources: ['wordlist.tsv'],
17
- punctuation: {
18
- quotesForKeepSuggestion: { open: `«`, close: `»`},
19
- insertAfterWord: " " , // OGHAM SPACE MARK
20
- }
21
- }, PATH) as string;
22
-
23
- // Check that the punctuation actually made into the code:
24
- assert.match(code, /«/);
25
- assert.match(code, /»/);
26
- // Ensure we inserted that OGHAM SPACE MARK!
27
- assert.match(code, /\u1680/);
28
-
29
- // Make sure it compiles!
30
- let compilation = compileModelSourceCode(code);
31
- assert.isFalse(compilation.hasSyntaxError);
32
- assert.isNotNull(compilation.exportedModel);
33
- });
34
- })
35
- });
@@ -1,22 +0,0 @@
1
- {
2
- "extends": "../../kmc/tsconfig.kmc-base.json",
3
-
4
- "compilerOptions": {
5
- "rootDir": ".",
6
- "rootDirs": ["./", "../src/"],
7
- "outDir": "../build/test",
8
- "esModuleInterop": true,
9
- "moduleResolution": "node16",
10
- "allowSyntheticDefaultImports": true,
11
- "baseUrl": ".",
12
- },
13
- "include": [
14
- "**/test-*.ts",
15
- "*.ts",
16
- "helpers/*.ts",
17
- "wordbreakers/*.ts"
18
- ],
19
- "references": [
20
- { "path": "../" },
21
- ]
22
- }
@@ -1,3 +0,0 @@
1
- Wordbreakers ES Module format
2
-
3
- TODO: once we move common/models/wordbreakers to ESM, eliminate this.