@keymanapp/kmc-model 17.0.85-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.
- package/.nyc_output/coverage-10524-1681239236645-0.json +1 -0
- package/Makefile +38 -0
- package/build/cjs-src/lexical-model-compiler.cjs +152688 -0
- package/build/src/build-trie.d.ts +40 -0
- package/build/src/build-trie.d.ts.map +1 -0
- package/build/src/build-trie.js +362 -0
- package/build/src/build-trie.js.map +1 -0
- package/build/src/join-word-breaker-decorator.d.ts +10 -0
- package/build/src/join-word-breaker-decorator.d.ts.map +1 -0
- package/build/src/join-word-breaker-decorator.js +121 -0
- package/build/src/join-word-breaker-decorator.js.map +1 -0
- package/build/src/lexical-model-compiler.d.ts +19 -0
- package/build/src/lexical-model-compiler.d.ts.map +1 -0
- package/build/src/lexical-model-compiler.js +155 -0
- package/build/src/lexical-model-compiler.js.map +1 -0
- package/build/src/lexical-model.d.ts +135 -0
- package/build/src/lexical-model.d.ts.map +1 -0
- package/build/src/lexical-model.js +6 -0
- package/build/src/lexical-model.js.map +1 -0
- package/build/src/main.d.ts +15 -0
- package/build/src/main.d.ts.map +1 -0
- package/build/src/main.js +46 -0
- package/build/src/main.js.map +1 -0
- package/build/src/model-compiler-errors.d.ts +77 -0
- package/build/src/model-compiler-errors.d.ts.map +1 -0
- package/build/src/model-compiler-errors.js +156 -0
- package/build/src/model-compiler-errors.js.map +1 -0
- package/build/src/model-defaults.d.ts +56 -0
- package/build/src/model-defaults.d.ts.map +1 -0
- package/build/src/model-defaults.js +106 -0
- package/build/src/model-defaults.js.map +1 -0
- package/build/src/model-definitions.d.ts +71 -0
- package/build/src/model-definitions.d.ts.map +1 -0
- package/build/src/model-definitions.js +189 -0
- package/build/src/model-definitions.js.map +1 -0
- package/build/src/script-overrides-decorator.d.ts +4 -0
- package/build/src/script-overrides-decorator.d.ts.map +1 -0
- package/build/src/script-overrides-decorator.js +63 -0
- package/build/src/script-overrides-decorator.js.map +1 -0
- package/build/test/helpers/index.d.ts +69 -0
- package/build/test/helpers/index.d.ts.map +1 -0
- package/build/test/helpers/index.js +160 -0
- package/build/test/helpers/index.js.map +1 -0
- package/build/test/test-compile-model-with-pseudoclosure.d.ts +2 -0
- package/build/test/test-compile-model-with-pseudoclosure.d.ts.map +1 -0
- package/build/test/test-compile-model-with-pseudoclosure.js +200 -0
- package/build/test/test-compile-model-with-pseudoclosure.js.map +1 -0
- package/build/test/test-compile-model.d.ts +2 -0
- package/build/test/test-compile-model.d.ts.map +1 -0
- package/build/test/test-compile-model.js +30 -0
- package/build/test/test-compile-model.js.map +1 -0
- package/build/test/test-compile-trie.d.ts +2 -0
- package/build/test/test-compile-trie.d.ts.map +1 -0
- package/build/test/test-compile-trie.js +125 -0
- package/build/test/test-compile-trie.js.map +1 -0
- package/build/test/test-default-apply-case.d.ts +2 -0
- package/build/test/test-default-apply-case.d.ts.map +1 -0
- package/build/test/test-default-apply-case.js +105 -0
- package/build/test/test-default-apply-case.js.map +1 -0
- package/build/test/test-default-search-term-to-key.d.ts +2 -0
- package/build/test/test-default-search-term-to-key.d.ts.map +1 -0
- package/build/test/test-default-search-term-to-key.js +148 -0
- package/build/test/test-default-search-term-to-key.js.map +1 -0
- package/build/test/test-error-logger.d.ts +2 -0
- package/build/test/test-error-logger.d.ts.map +1 -0
- package/build/test/test-error-logger.js +26 -0
- package/build/test/test-error-logger.js.map +1 -0
- package/build/test/test-join-word-breaker.d.ts +2 -0
- package/build/test/test-join-word-breaker.d.ts.map +1 -0
- package/build/test/test-join-word-breaker.js +84 -0
- package/build/test/test-join-word-breaker.js.map +1 -0
- package/build/test/test-model-definitions.d.ts +2 -0
- package/build/test/test-model-definitions.d.ts.map +1 -0
- package/build/test/test-model-definitions.js +165 -0
- package/build/test/test-model-definitions.js.map +1 -0
- package/build/test/test-override-script-defaults.d.ts +2 -0
- package/build/test/test-override-script-defaults.d.ts.map +1 -0
- package/build/test/test-override-script-defaults.js +28 -0
- package/build/test/test-override-script-defaults.js.map +1 -0
- package/build/test/test-parse-wordlist.d.ts +2 -0
- package/build/test/test-parse-wordlist.d.ts.map +1 -0
- package/build/test/test-parse-wordlist.js +110 -0
- package/build/test/test-parse-wordlist.js.map +1 -0
- package/build/test/test-punctuation.d.ts +2 -0
- package/build/test/test-punctuation.d.ts.map +1 -0
- package/build/test/test-punctuation.js +31 -0
- package/build/test/test-punctuation.js.map +1 -0
- package/build/test/tsconfig.tsbuildinfo +1 -0
- package/build/test/wordbreakers/data.d.ts +35 -0
- package/build/test/wordbreakers/data.d.ts.map +1 -0
- package/build/test/wordbreakers/data.js +1778 -0
- package/build/test/wordbreakers/data.js.map +1 -0
- package/build/test/wordbreakers/default-wordbreaker-esm.d.ts +10 -0
- package/build/test/wordbreakers/default-wordbreaker-esm.d.ts.map +1 -0
- package/build/test/wordbreakers/default-wordbreaker-esm.js +354 -0
- package/build/test/wordbreakers/default-wordbreaker-esm.js.map +1 -0
- package/build/tsconfig.tsbuildinfo +1 -0
- package/build.sh +73 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +161 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov-report/src/build-trie.ts.html +1618 -0
- package/coverage/lcov-report/src/index.html +221 -0
- package/coverage/lcov-report/src/join-word-breaker-decorator.ts.html +487 -0
- package/coverage/lcov-report/src/lexical-model-compiler.ts.html +622 -0
- package/coverage/lcov-report/src/main.ts.html +271 -0
- package/coverage/lcov-report/src/model-compiler-errors.ts.html +691 -0
- package/coverage/lcov-report/src/model-defaults.ts.html +415 -0
- package/coverage/lcov-report/src/model-definitions.ts.html +748 -0
- package/coverage/lcov-report/src/script-overrides-decorator.ts.html +310 -0
- package/coverage/lcov-report/test/helpers/index.html +116 -0
- package/coverage/lcov-report/test/helpers/index.ts.html +646 -0
- package/coverage/lcov-report/test/index.html +266 -0
- package/coverage/lcov-report/test/test-compile-model-with-pseudoclosure.ts.html +802 -0
- package/coverage/lcov-report/test/test-compile-model.ts.html +187 -0
- package/coverage/lcov-report/test/test-compile-trie.ts.html +541 -0
- package/coverage/lcov-report/test/test-default-apply-case.ts.html +466 -0
- package/coverage/lcov-report/test/test-default-search-term-to-key.ts.html +628 -0
- package/coverage/lcov-report/test/test-error-logger.ts.html +196 -0
- package/coverage/lcov-report/test/test-join-word-breaker.ts.html +376 -0
- package/coverage/lcov-report/test/test-model-definitions.ts.html +676 -0
- package/coverage/lcov-report/test/test-override-script-defaults.ts.html +184 -0
- package/coverage/lcov-report/test/test-parse-wordlist.ts.html +466 -0
- package/coverage/lcov-report/test/test-punctuation.ts.html +190 -0
- package/coverage/lcov-report/test/wordbreakers/data.ts.html +5413 -0
- package/coverage/lcov-report/test/wordbreakers/default-wordbreaker-esm.ts.html +1234 -0
- package/coverage/lcov-report/test/wordbreakers/index.html +131 -0
- package/coverage/lcov.info +5969 -0
- package/package.json +61 -0
- package/src/build-trie.ts +511 -0
- package/src/join-word-breaker-decorator.ts +134 -0
- package/src/lexical-model-compiler.ts +179 -0
- package/src/lexical-model.ts +150 -0
- package/src/main.ts +62 -0
- package/src/model-compiler-errors.ts +203 -0
- package/src/model-defaults.ts +111 -0
- package/src/model-definitions.ts +222 -0
- package/src/script-overrides-decorator.ts +75 -0
- package/test/README.md +15 -0
- package/test/fixtures/example.qaa.joinwordbreaker/example.qaa.joinwordbreaker.model.ts +10 -0
- package/test/fixtures/example.qaa.joinwordbreaker/wordlist.tsv +3 -0
- package/test/fixtures/example.qaa.scriptusesspaces/example.qaa.scriptusesspaces.model.ts +10 -0
- package/test/fixtures/example.qaa.scriptusesspaces/wordlist.tsv +8 -0
- package/test/fixtures/example.qaa.sencoten/example.qaa.sencoten.model.kmp.json +45 -0
- package/test/fixtures/example.qaa.sencoten/example.qaa.sencoten.model.kps +35 -0
- package/test/fixtures/example.qaa.sencoten/example.qaa.sencoten.model.ts +6 -0
- package/test/fixtures/example.qaa.sencoten/wordlist.tsv +10 -0
- package/test/fixtures/example.qaa.smp/example.qaa.smp.model.ts +6 -0
- package/test/fixtures/example.qaa.smp/wordlist.tsv +5 -0
- package/test/fixtures/example.qaa.trivial/example.qaa.trivial.model.ts +5 -0
- package/test/fixtures/example.qaa.trivial/wordlist.tsv +3 -0
- package/test/fixtures/example.qaa.utf16be/example.qaa.utf16be.model.ts +5 -0
- package/test/fixtures/example.qaa.utf16be/wordlist.txt +0 -0
- package/test/fixtures/example.qaa.utf16le/example.qaa.utf16le.model.ts +5 -0
- package/test/fixtures/example.qaa.utf16le/wordlist.txt +0 -0
- package/test/fixtures/example.qaa.wordbreaker/example.qaa.wordbreaker.model.ts +9 -0
- package/test/fixtures/example.qaa.wordbreaker/wordlist.tsv +3 -0
- package/test/helpers/index.ts +187 -0
- package/test/test-compile-model-with-pseudoclosure.ts +239 -0
- package/test/test-compile-model.ts +34 -0
- package/test/test-compile-trie.ts +152 -0
- package/test/test-default-apply-case.ts +128 -0
- package/test/test-default-search-term-to-key.ts +181 -0
- package/test/test-error-logger.ts +38 -0
- package/test/test-join-word-breaker.ts +97 -0
- package/test/test-model-definitions.ts +198 -0
- package/test/test-override-script-defaults.ts +33 -0
- package/test/test-parse-wordlist.ts +127 -0
- package/test/test-punctuation.ts +35 -0
- package/test/tsconfig.json +22 -0
- package/test/wordbreakers/README.md +3 -0
- package/test/wordbreakers/data.ts +1776 -0
- package/test/wordbreakers/default-wordbreaker-esm.ts +383 -0
- package/tools/create-override-script-regexp.ts +145 -0
- package/tsconfig.json +17 -0
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/// <reference types="@keymanapp/models-types" />
|
|
2
|
+
/**
|
|
3
|
+
* Helpers and utilities for the Mocha tests.
|
|
4
|
+
*/
|
|
5
|
+
import * as path from 'path';
|
|
6
|
+
import { fileURLToPath } from 'url';
|
|
7
|
+
import { assert } from 'chai';
|
|
8
|
+
import { redirectLogMessagesTo, resetLogMessageHandler, LogLevel } from '../../src/model-compiler-errors.js';
|
|
9
|
+
/**
|
|
10
|
+
* Builds a path to the fixture with the given path components.
|
|
11
|
+
*
|
|
12
|
+
* e.g., makePathToFixture('example.qaa.trivial')
|
|
13
|
+
* e.g., makePathToFixture('example.qaa.trivial', 'model.ts')
|
|
14
|
+
*
|
|
15
|
+
* @param components One or more path components.
|
|
16
|
+
*/
|
|
17
|
+
export function makePathToFixture(...components) {
|
|
18
|
+
return fileURLToPath(new URL(path.join('..', '..', '..', 'test', 'fixtures', ...components), import.meta.url));
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Given source code of a model (as produced by the compiler), this evaluates
|
|
22
|
+
* it!
|
|
23
|
+
*
|
|
24
|
+
* That way, you can determine if the source code was syntactically-valid,
|
|
25
|
+
* whether it raise an exception during construction, and you can even inspect
|
|
26
|
+
* the resultant LexicalModel for yourself!
|
|
27
|
+
*
|
|
28
|
+
* @param code
|
|
29
|
+
*/
|
|
30
|
+
export function compileModelSourceCode(code) {
|
|
31
|
+
assert.typeOf(code, 'string');
|
|
32
|
+
let error = null;
|
|
33
|
+
let exportedModel = null;
|
|
34
|
+
let hasSyntaxError = false;
|
|
35
|
+
let modelConstructorName = null;
|
|
36
|
+
let module = null;
|
|
37
|
+
try {
|
|
38
|
+
module = new Function('LMLayerWorker', 'models', 'wordBreakers', code);
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
if (err instanceof SyntaxError) {
|
|
42
|
+
hasSyntaxError = true;
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
throw err;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
// Module had some sort of syntax error:
|
|
49
|
+
if (module === null) {
|
|
50
|
+
return {
|
|
51
|
+
error, exportedModel, hasSyntaxError, modelConstructorName
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
let fakeLMLayerWorker = {
|
|
55
|
+
loadModel(model) {
|
|
56
|
+
exportedModel = model;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
// We expect the compiled model to reach into the `models` namespace,
|
|
60
|
+
// and get some sort of model constructor. Problem is, we don't know
|
|
61
|
+
// what model constructors are defined!
|
|
62
|
+
// This proxy allows us to intercept
|
|
63
|
+
// models.*
|
|
64
|
+
// meaning that when the compiled code tries to do this:
|
|
65
|
+
//
|
|
66
|
+
// new models.WhateverModel('foo', 'bar')
|
|
67
|
+
//
|
|
68
|
+
// ...we can intercept the name "WhateverModel" and assign it to
|
|
69
|
+
// `modelConstructorName`.
|
|
70
|
+
let modelsNamespace = new Proxy({}, {
|
|
71
|
+
get(_target, property) {
|
|
72
|
+
if (typeof property !== 'string')
|
|
73
|
+
throw new Error(`Don't know how to handle non-string property: ${String(property)}`);
|
|
74
|
+
return class DummyModel {
|
|
75
|
+
constructor() {
|
|
76
|
+
modelConstructorName = property;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
// We expect the compiled model to reach into the `wordBreaker` namespace,
|
|
82
|
+
// and maybe get a function. Problem is, we don't know
|
|
83
|
+
// what functions are available!
|
|
84
|
+
// This proxy allows us to intercept
|
|
85
|
+
// wordBreakers.*
|
|
86
|
+
// meaning that when the compiled code tries to do this:
|
|
87
|
+
//
|
|
88
|
+
// wordBreaker["someWordBreaker"]
|
|
89
|
+
//
|
|
90
|
+
// ...we can intercept the name "someWordBreaker".
|
|
91
|
+
let wordBreakerNamespace = new Proxy({}, {
|
|
92
|
+
get(_target, property) {
|
|
93
|
+
if (typeof property !== 'string')
|
|
94
|
+
throw new Error(`Don't know how to handle non-string property: ${String(property)}`);
|
|
95
|
+
return function dummyWordBreaker() {
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
try {
|
|
100
|
+
module(fakeLMLayerWorker, modelsNamespace, wordBreakerNamespace);
|
|
101
|
+
}
|
|
102
|
+
catch (err) {
|
|
103
|
+
error = err;
|
|
104
|
+
}
|
|
105
|
+
return {
|
|
106
|
+
error, exportedModel, hasSyntaxError, modelConstructorName
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Enables one to query log messages after they have been logged.
|
|
111
|
+
*/
|
|
112
|
+
export class LogHoarder {
|
|
113
|
+
messages = [];
|
|
114
|
+
/**
|
|
115
|
+
* Get rid of all log messages seen.
|
|
116
|
+
*/
|
|
117
|
+
clear() {
|
|
118
|
+
this.messages = [];
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Hoards a log message for later perusal.
|
|
122
|
+
*/
|
|
123
|
+
handleLog(log) {
|
|
124
|
+
this.messages.push(log);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Has an error message with this code been witnessed?
|
|
128
|
+
*/
|
|
129
|
+
hasSeenCode(code) {
|
|
130
|
+
return Boolean(this.messages.find(log => log.code === code));
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Have any warnings been logged?
|
|
134
|
+
*/
|
|
135
|
+
hasSeenWarnings() {
|
|
136
|
+
return this.messages
|
|
137
|
+
.filter(log => log.level === LogLevel.CERR_WARNING)
|
|
138
|
+
.length > 0;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Overrides the global log handler, allowing one to browse log messages
|
|
142
|
+
* later.
|
|
143
|
+
*
|
|
144
|
+
* Remember to uninstall the log handler afterwards!
|
|
145
|
+
*/
|
|
146
|
+
install() {
|
|
147
|
+
redirectLogMessagesTo(this.handleLog.bind(this));
|
|
148
|
+
return this;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Return the log message handler to its default.
|
|
152
|
+
*
|
|
153
|
+
* Note: You MUST uninstall the hoarder after use!
|
|
154
|
+
* It's recommended you put this in an afterEach() callback.
|
|
155
|
+
*/
|
|
156
|
+
uninstall() {
|
|
157
|
+
resetLogMessageHandler();
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../test/helpers/index.ts"],"names":[],"mappings":"AAAA,iDAAiD;AAEjD;;GAEG;AACH,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAC,MAAM,EAAC,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAkC,qBAAqB,EAAE,sBAAsB,EAAE,QAAQ,EAAC,MAAM,oCAAoC,CAAC;AAS5I;;;;;;;GAOG;AACF,MAAM,UAAU,iBAAiB,CAAC,GAAG,UAAoB;IACxD,OAAO,aAAa,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,UAAU,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AACjH,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,sBAAsB,CAAC,IAAY;IACjD,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAE9B,IAAI,KAAK,GAAiB,IAAI,CAAC;IAC/B,IAAI,aAAa,GAAkB,IAAI,CAAC;IACxC,IAAI,cAAc,GAAG,KAAK,CAAC;IAC3B,IAAI,oBAAoB,GAAkB,IAAI,CAAC;IAE/C,IAAI,MAAM,GAAsB,IAAI,CAAC;IACrC,IAAI;QACF,MAAM,GAAG,IAAI,QAAQ,CAAC,eAAe,EAAE,QAAQ,EAAE,cAAc,EAAE,IAAI,CAAe,CAAC;KACtF;IAAC,OAAO,GAAG,EAAE;QACZ,IAAI,GAAG,YAAY,WAAW,EAAE;YAC9B,cAAc,GAAG,IAAI,CAAC;SACvB;aAAM;YACL,MA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C,CAAC;KAClE;IAAC,OAAO,GAAG,EAAE;QACZ,KAAK,GAAG,GAAG,CAAC;KACb;IAED,OAAO;QACL,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,oBAAoB;KAC3D,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,OAAO,UAAU;IACb,QAAQ,GAAiB,EAAE,CAAC;IAEpC;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;IACrB,CAAC;IAED;;OAEG;IACH,SAAS,CAAC,GAAe;QACvB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC1B,CAAC;IAED;;OAEG;IACH,WAAW,CAAC,IAAyB;QACnC,OAAO,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC;IAC/D,CAAC;IAED;;OAEG;IACH,eAAe;QACb,OAAO,IAAI,CAAC,QAAQ;aACjB,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,KAAK,KAAK,QAAQ,CAAC,YAAY,CAAC;aAClD,MAAM,GAAG,CAAC,CAAC;IAChB,CAAC;IAED;;;;;OAKG;IACH,OAAO;QACL,qBAAqB,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QACjD,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;OAKG;IACH,SAAS;QACP,sBAAsB,EAAE,CAAA;IAC1B,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-compile-model-with-pseudoclosure.d.ts","sourceRoot":"","sources":["../../test/test-compile-model-with-pseudoclosure.ts"],"names":[],"mappings":"AAEA,OAAO,OAAO,CAAC"}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import LexicalModelCompiler from '../src/lexical-model-compiler.js';
|
|
2
|
+
import { assert } from 'chai';
|
|
3
|
+
import 'mocha';
|
|
4
|
+
import { makePathToFixture, compileModelSourceCode } from './helpers/index.js';
|
|
5
|
+
describe('LexicalModelCompiler - pseudoclosure compilation + use', function () {
|
|
6
|
+
const MODEL_ID = 'example.qaa.trivial';
|
|
7
|
+
const PATH = makePathToFixture(MODEL_ID);
|
|
8
|
+
describe('specifying custom methods: applyCasing and searchTermToKey', function () {
|
|
9
|
+
let casingWithPrependedSymbols = function (casingName, text, defaultApplyCasing) {
|
|
10
|
+
switch (casingName) {
|
|
11
|
+
// Use of symbols, and of the `casingName` name, exist to serve as regex targets.
|
|
12
|
+
case 'lower':
|
|
13
|
+
return '-' + defaultApplyCasing(casingName, text);
|
|
14
|
+
case 'upper':
|
|
15
|
+
return '+' + defaultApplyCasing(casingName, text);
|
|
16
|
+
case 'initial':
|
|
17
|
+
return '^' + defaultApplyCasing(casingName, text);
|
|
18
|
+
default:
|
|
19
|
+
return defaultApplyCasing(casingName, text);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
it('variant 1: applyCasing prepends symbols, searchTermToKey removes them', function () {
|
|
23
|
+
let compiler = new LexicalModelCompiler;
|
|
24
|
+
let code = compiler.generateLexicalModelCode(MODEL_ID, {
|
|
25
|
+
format: 'trie-1.0',
|
|
26
|
+
sources: ['wordlist.tsv'],
|
|
27
|
+
languageUsesCasing: true,
|
|
28
|
+
applyCasing: casingWithPrependedSymbols,
|
|
29
|
+
// Parameter name `rawSearchTerm` selected for uniqueness, regex matching test target.
|
|
30
|
+
searchTermToKey: function (rawSearchTerm, applyCasing) {
|
|
31
|
+
// Strips any applyCasing symbols ('-', '+', '^') out of the compiled Trie.
|
|
32
|
+
// We should be able to test that they do _not_ occur within internal nodes of the Trie.
|
|
33
|
+
return applyCasing('lower', rawSearchTerm)
|
|
34
|
+
// We replace all prepended applyCasing symbols with a separate symbol not
|
|
35
|
+
// otherwise seen within the model.
|
|
36
|
+
.replace(/^-/, '§')
|
|
37
|
+
.replace(/^\+/, '§')
|
|
38
|
+
.replace(/^\^/, '§');
|
|
39
|
+
}
|
|
40
|
+
}, PATH);
|
|
41
|
+
// Check that pseudoclosure forwarding is set up correctly.
|
|
42
|
+
assert.match(code, /\.model\.searchTermToKey/);
|
|
43
|
+
assert.match(code, /\.model\.applyCasing/);
|
|
44
|
+
// Check that the methods actually made into the code; use our custom parameter names:
|
|
45
|
+
assert.match(code, /casingName/);
|
|
46
|
+
assert.match(code, /rawSearchTerm/);
|
|
47
|
+
// Check that the prepended symbols from applyCasing also appear in the code:
|
|
48
|
+
assert.match(code, /'-'/);
|
|
49
|
+
assert.match(code, /'\+'/);
|
|
50
|
+
assert.match(code, /'\^'/);
|
|
51
|
+
assert.match(code, /§/);
|
|
52
|
+
let modelInitIndex = code.indexOf('LMLayerWorker.loadModel');
|
|
53
|
+
let modelInitCode = code.substring(modelInitIndex);
|
|
54
|
+
// Chop off the IIFE terminator. Not strictly necessary, but whatever.
|
|
55
|
+
modelInitCode = modelInitCode.substring(0, modelInitCode.lastIndexOf('\n})();'));
|
|
56
|
+
// Check that the prepended symbols from applyCasing do not appear in the Trie.
|
|
57
|
+
assert.notMatch(modelInitCode, /['"]-['"]/);
|
|
58
|
+
assert.notMatch(modelInitCode, /['"]\+['"]/);
|
|
59
|
+
assert.notMatch(modelInitCode, /['"]\^['"]/);
|
|
60
|
+
// Instead, our custom keyer should ensure that the following symbol DOES appear.
|
|
61
|
+
// Verifies that the compiler uses the custom searchTermToKey definition.
|
|
62
|
+
assert.match(modelInitCode, /['"]§['"]/);
|
|
63
|
+
// Make sure it compiles!
|
|
64
|
+
let compilation = compileModelSourceCode(code);
|
|
65
|
+
assert.isFalse(compilation.hasSyntaxError);
|
|
66
|
+
assert.isNotNull(compilation.exportedModel);
|
|
67
|
+
});
|
|
68
|
+
it('variant 2: applyCasing prepends symbols, searchTermToKey keeps them', function () {
|
|
69
|
+
let compiler = new LexicalModelCompiler;
|
|
70
|
+
let code = compiler.generateLexicalModelCode(MODEL_ID, {
|
|
71
|
+
format: 'trie-1.0',
|
|
72
|
+
sources: ['wordlist.tsv'],
|
|
73
|
+
languageUsesCasing: true,
|
|
74
|
+
applyCasing: casingWithPrependedSymbols,
|
|
75
|
+
// Parameter name `rawSearchTerm` selected for uniqueness, regex matching test target.
|
|
76
|
+
searchTermToKey: function (rawSearchTerm, applyCasing) {
|
|
77
|
+
// Strips any applyCasing symbols ('-', '+', '^') out of the compiled Trie.
|
|
78
|
+
// We should be able to test that they do _not_ occur within internal nodes of the Trie.
|
|
79
|
+
return applyCasing('lower', rawSearchTerm);
|
|
80
|
+
}
|
|
81
|
+
}, PATH);
|
|
82
|
+
// Check that pseudoclosure forwarding is set up correctly.
|
|
83
|
+
assert.match(code, /\.model\.searchTermToKey/);
|
|
84
|
+
assert.match(code, /\.model\.applyCasing/);
|
|
85
|
+
// Check that the methods actually made into the code; use our custom parameter names:
|
|
86
|
+
assert.match(code, /casingName/);
|
|
87
|
+
assert.match(code, /rawSearchTerm/);
|
|
88
|
+
// Check that the prepended symbols from applyCasing also appear in the code:
|
|
89
|
+
assert.match(code, /'-'/);
|
|
90
|
+
assert.match(code, /'\+'/);
|
|
91
|
+
assert.match(code, /'\^'/);
|
|
92
|
+
let modelInitIndex = code.indexOf('LMLayerWorker.loadModel');
|
|
93
|
+
let modelInitCode = code.substring(modelInitIndex);
|
|
94
|
+
// Chop off the IIFE terminator. Not strictly necessary, but whatever.
|
|
95
|
+
modelInitCode = modelInitCode.substring(0, modelInitCode.lastIndexOf('\n})();'));
|
|
96
|
+
// Check that the prepended lowercase "-" DOES appear within the Trie, as keying
|
|
97
|
+
// does not remove it in this variant. Verifies that the compiler actually
|
|
98
|
+
// used the custom applyCasing definition!
|
|
99
|
+
assert.match(modelInitCode, /['"]-['"]/);
|
|
100
|
+
// Make sure it compiles!
|
|
101
|
+
let compilation = compileModelSourceCode(code);
|
|
102
|
+
assert.isFalse(compilation.hasSyntaxError);
|
|
103
|
+
assert.isNotNull(compilation.exportedModel);
|
|
104
|
+
});
|
|
105
|
+
it('variant 3: applyCasing prepends symbols, default searchTermToKey', function () {
|
|
106
|
+
let compiler = new LexicalModelCompiler;
|
|
107
|
+
let code = compiler.generateLexicalModelCode(MODEL_ID, {
|
|
108
|
+
format: 'trie-1.0',
|
|
109
|
+
sources: ['wordlist.tsv'],
|
|
110
|
+
languageUsesCasing: true,
|
|
111
|
+
applyCasing: casingWithPrependedSymbols
|
|
112
|
+
}, PATH);
|
|
113
|
+
// Check that pseudoclosure forwarding is set up correctly.
|
|
114
|
+
assert.match(code, /\.model\.searchTermToKey/);
|
|
115
|
+
assert.match(code, /\.model\.applyCasing/);
|
|
116
|
+
// Check that the methods actually made into the code; use our custom parameter names:
|
|
117
|
+
assert.match(code, /casingName/);
|
|
118
|
+
assert.match(code, /function defaultCasedSearchTermToKey/);
|
|
119
|
+
// Check that the prepended symbols from applyCasing also appear in the code:
|
|
120
|
+
assert.match(code, /'-'/);
|
|
121
|
+
assert.match(code, /'\+'/);
|
|
122
|
+
assert.match(code, /'\^'/);
|
|
123
|
+
let modelInitIndex = code.indexOf('LMLayerWorker.loadModel');
|
|
124
|
+
let modelInitCode = code.substring(modelInitIndex);
|
|
125
|
+
// Chop off the IIFE terminator. Not strictly necessary, but whatever.
|
|
126
|
+
modelInitCode = modelInitCode.substring(0, modelInitCode.lastIndexOf('\n})();'));
|
|
127
|
+
// Check that the prepended lowercase "-" DOES appear within the Trie, as keying
|
|
128
|
+
// does not remove it in this variant. Verifies that the compiler actually
|
|
129
|
+
// used the custom applyCasing definition!
|
|
130
|
+
assert.match(modelInitCode, /['"]-['"]/);
|
|
131
|
+
// Make sure it compiles!
|
|
132
|
+
let compilation = compileModelSourceCode(code);
|
|
133
|
+
assert.isFalse(compilation.hasSyntaxError);
|
|
134
|
+
assert.isNotNull(compilation.exportedModel);
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
describe('relying on default applyCasing + searchTermToKey', function () {
|
|
138
|
+
it('languageUsesCasing: true', function () {
|
|
139
|
+
let compiler = new LexicalModelCompiler;
|
|
140
|
+
let code = compiler.generateLexicalModelCode(MODEL_ID, {
|
|
141
|
+
format: 'trie-1.0',
|
|
142
|
+
sources: ['wordlist.tsv'],
|
|
143
|
+
languageUsesCasing: true, // applyCasing should appear!
|
|
144
|
+
}, PATH);
|
|
145
|
+
// Does the cased version of the search-term default appear?
|
|
146
|
+
assert.match(code, /function defaultCasedSearchTermToKey/);
|
|
147
|
+
assert.match(code, /\.model\.searchTermToKey/);
|
|
148
|
+
// Does the default casing function appear?
|
|
149
|
+
assert.match(code, /function defaultApplyCasing/);
|
|
150
|
+
assert.match(code, /\.defaults\.applyCasing/);
|
|
151
|
+
assert.match(code, /languageUsesCasing/);
|
|
152
|
+
// Make sure it compiles!
|
|
153
|
+
let compilation = compileModelSourceCode(code);
|
|
154
|
+
assert.isFalse(compilation.hasSyntaxError);
|
|
155
|
+
assert.isNotNull(compilation.exportedModel);
|
|
156
|
+
});
|
|
157
|
+
it('languageUsesCasing: false', function () {
|
|
158
|
+
let compiler = new LexicalModelCompiler;
|
|
159
|
+
let code = compiler.generateLexicalModelCode(MODEL_ID, {
|
|
160
|
+
format: 'trie-1.0',
|
|
161
|
+
sources: ['wordlist.tsv'],
|
|
162
|
+
languageUsesCasing: false, // applyCasing should not appear!
|
|
163
|
+
}, PATH);
|
|
164
|
+
// Does the cased version of the search-term default appear?
|
|
165
|
+
assert.match(code, /function defaultSearchTermToKey/);
|
|
166
|
+
assert.match(code, /\.model\.searchTermToKey/);
|
|
167
|
+
// Does the default casing function appear?
|
|
168
|
+
// Since `languageUsesCasing` is explicitly `false`, there should be no usage.
|
|
169
|
+
assert.notMatch(code, /function defaultApplyCasing/);
|
|
170
|
+
assert.notMatch(code, /\.defaults\.applyCasing/);
|
|
171
|
+
assert.match(code, /languageUsesCasing/);
|
|
172
|
+
// Make sure it compiles!
|
|
173
|
+
let compilation = compileModelSourceCode(code);
|
|
174
|
+
assert.isFalse(compilation.hasSyntaxError);
|
|
175
|
+
assert.isNotNull(compilation.exportedModel);
|
|
176
|
+
});
|
|
177
|
+
it('languageUsesCasing: undefined', function () {
|
|
178
|
+
let compiler = new LexicalModelCompiler;
|
|
179
|
+
let code = compiler.generateLexicalModelCode(MODEL_ID, {
|
|
180
|
+
format: 'trie-1.0',
|
|
181
|
+
sources: ['wordlist.tsv']
|
|
182
|
+
// languageUsesCasing: undefined
|
|
183
|
+
}, PATH);
|
|
184
|
+
// Does the cased version of the search-term default appear?
|
|
185
|
+
// Needed to match 14.0 defaults.
|
|
186
|
+
assert.match(code, /function defaultCasedSearchTermToKey/);
|
|
187
|
+
assert.match(code, /\.model\.searchTermToKey/);
|
|
188
|
+
// Does the default casing function appear?
|
|
189
|
+
assert.match(code, /function defaultApplyCasing/);
|
|
190
|
+
assert.match(code, /\.defaults\.applyCasing/);
|
|
191
|
+
// Did the compilation process explictly leave `languageUsesCasing` undefined?
|
|
192
|
+
assert.notMatch(code, /languageUsesCasing/);
|
|
193
|
+
// Make sure it compiles!
|
|
194
|
+
let compilation = compileModelSourceCode(code);
|
|
195
|
+
assert.isFalse(compilation.hasSyntaxError);
|
|
196
|
+
assert.isNotNull(compilation.exportedModel);
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
});
|
|
200
|
+
//# sourceMappingURL=test-compile-model-with-pseudoclosure.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-compile-model-with-pseudoclosure.js","sourceRoot":"","sources":["../../test/test-compile-model-with-pseudoclosure.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAC,MAAM,EAAC,MAAM,MAAM,CAAC;AAC5B,OAAO,OAAO,CAAC;AAEf,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAE/E,QAAQ,CAAC,wDAAwD,EAAE;IACjE,MAAM,QAAQ,GAAG,qBAAqB,CAA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,iCAAiC;YACjC,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,sCAAsC,CAAC,CAAC;YAC3D,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,0BAA0B,CAAC,CAAC;YAE/C,2CAA2C;YAC3C,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,6BAA6B,CAAC,CAAC;YAClD,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,yBAAyB,CAAC,CAAC;YAE9C,8EAA8E;YAC9E,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,oBAAoB,CAAC,CAAC;YAE5C,yBAAyB;YACzB,IAAI,WAAW,GAAG,sBAAsB,CAAC,IAAI,CAAC,CAAC;YAC/C,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;YAC3C,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;QAC9C,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-compile-model.d.ts","sourceRoot":"","sources":["../../test/test-compile-model.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import 'mocha';
|
|
2
|
+
import { assert } from 'chai';
|
|
3
|
+
import { compileModel } from '../src/main.js';
|
|
4
|
+
import { makePathToFixture, compileModelSourceCode } from './helpers/index.js';
|
|
5
|
+
describe('compileModel', function () {
|
|
6
|
+
// Try to compile ALL of the correct models.
|
|
7
|
+
const MODELS = [
|
|
8
|
+
'example.qaa.sencoten',
|
|
9
|
+
'example.qaa.trivial',
|
|
10
|
+
'example.qaa.utf16le',
|
|
11
|
+
'example.qaa.wordbreaker',
|
|
12
|
+
'example.qaa.joinwordbreaker',
|
|
13
|
+
'example.qaa.scriptusesspaces',
|
|
14
|
+
];
|
|
15
|
+
for (let modelID of MODELS) {
|
|
16
|
+
let modelPath = makePathToFixture(modelID, `${modelID}.model.ts`);
|
|
17
|
+
it(`should compile ${modelID}`, function () {
|
|
18
|
+
let code = compileModel(modelPath);
|
|
19
|
+
let r;
|
|
20
|
+
assert.doesNotThrow(() => {
|
|
21
|
+
r = compileModelSourceCode(code);
|
|
22
|
+
});
|
|
23
|
+
let compilation = r;
|
|
24
|
+
assert.isFalse(compilation.hasSyntaxError, 'model code had syntax error');
|
|
25
|
+
assert.isNull(compilation.error, `compilation error: ${compilation.error}`);
|
|
26
|
+
assert.equal(compilation.modelConstructorName, 'TrieModel');
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
//# sourceMappingURL=test-compile-model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-compile-model.js","sourceRoot":"","sources":["../../test/test-compile-model.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,CAAC;AACf,OAAO,EAAC,MAAM,EAAC,MAAM,MAAM,CAAC;AAE5B,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAC,iBAAiB,EAAE,sBAAsB,EAAoB,MAAM,oBAAoB,CAAC;AAEhG,QAAQ,CAAC,cAAc,EAAE;IACvB,4CAA4C;IAC5C,MAAM,MAAM,GAAG;QACb,sBAAsB;QACtB,qBAAqB;QACrB,qBAAqB;QACrB,yBAAyB;QACzB,6BAA6B;QAC7B,8BAA8B;KAC/B,CAAC;IAEF,KAAK,IAAI,OAAO,IAAI,MAAM,EAAE;QAC1B,IAAI,SAAS,GAAG,iBAAiB,CAAC,OAAO,EAAE,GAAG,OAAO,WAAW,CAAC,CAAC;QAElE,EAAE,CAAC,kBAAkB,OAAO,EAAE,EAAE;YAC9B,IAAI,IAAI,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC;YACnC,IAAI,CAAU,CAAC;YACf,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE;gBACvB,CAAC,GAAG,sBAAsB,CAAC,IAAI,CAAC,CAAC;YACnC,CAAC,CAAC,CAAC;YACH,IAAI,WAAW,GAAG,CAAsB,CAAC;YAEzC,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,cAAc,EAAE,6BAA6B,CAAC,CAAC;YAC1E,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,sBAAsB,WAAW,CAAC,KAAK,EAAE,CAAC,CAAC;YAC5E,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,oBAAoB,EAAE,WAAW,CAAC,CAAC;QAC9D,CAAC,CAAC,CAAC;KACJ;AACH,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-compile-trie.d.ts","sourceRoot":"","sources":["../../test/test-compile-trie.ts"],"names":[],"mappings":"AAEA,OAAO,OAAO,CAAC"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import LexicalModelCompiler from '../src/lexical-model-compiler.js';
|
|
2
|
+
import { assert } from 'chai';
|
|
3
|
+
import 'mocha';
|
|
4
|
+
import { makePathToFixture, compileModelSourceCode } from './helpers/index.js';
|
|
5
|
+
import { createTrieDataStructure } from '../src/build-trie.js';
|
|
6
|
+
describe('LexicalModelCompiler', function () {
|
|
7
|
+
describe('#generateLexicalModelCode', function () {
|
|
8
|
+
it('should compile a trivial word list', function () {
|
|
9
|
+
const MODEL_ID = 'example.qaa.trivial';
|
|
10
|
+
const PATH = makePathToFixture(MODEL_ID);
|
|
11
|
+
let compiler = new LexicalModelCompiler;
|
|
12
|
+
let code = compiler.generateLexicalModelCode(MODEL_ID, {
|
|
13
|
+
format: 'trie-1.0',
|
|
14
|
+
sources: ['wordlist.tsv']
|
|
15
|
+
}, PATH);
|
|
16
|
+
let result = compileModelSourceCode(code);
|
|
17
|
+
assert.isFalse(result.hasSyntaxError);
|
|
18
|
+
assert.isNotNull(result.exportedModel);
|
|
19
|
+
assert.equal(result.modelConstructorName, 'TrieModel');
|
|
20
|
+
// Sanity check: the word list has three total unweighted words, with a
|
|
21
|
+
// total weight of 3!
|
|
22
|
+
assert.match(code, /\btotalWeight\b["']?:\s*3\b/);
|
|
23
|
+
// Sanity check: the word breaker is a property of the object.
|
|
24
|
+
assert.match(code, /\bwordBreaker\b["']?:\s*wordBreakers\b/);
|
|
25
|
+
});
|
|
26
|
+
it('should compile a word list exported by Microsoft Excel', function () {
|
|
27
|
+
const MODEL_ID = 'example.qaa.utf16le';
|
|
28
|
+
const PATH = makePathToFixture(MODEL_ID);
|
|
29
|
+
let compiler = new LexicalModelCompiler;
|
|
30
|
+
let code = compiler.generateLexicalModelCode(MODEL_ID, {
|
|
31
|
+
format: 'trie-1.0',
|
|
32
|
+
sources: ['wordlist.txt']
|
|
33
|
+
}, PATH);
|
|
34
|
+
let result = compileModelSourceCode(code);
|
|
35
|
+
assert.isFalse(result.hasSyntaxError);
|
|
36
|
+
assert.isNotNull(result.exportedModel);
|
|
37
|
+
assert.equal(result.modelConstructorName, 'TrieModel');
|
|
38
|
+
// Sanity check: the word list has three total unweighted words, with a
|
|
39
|
+
// total weight of 44,103!
|
|
40
|
+
assert.match(code, /\btotalWeight\b["']?:\s*44103\b/);
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
it('should compile a word list with a custom word breaking function', function () {
|
|
44
|
+
const MODEL_ID = 'example.qaa.trivial';
|
|
45
|
+
const PATH = makePathToFixture(MODEL_ID);
|
|
46
|
+
let compiler = new LexicalModelCompiler;
|
|
47
|
+
let code = compiler.generateLexicalModelCode(MODEL_ID, {
|
|
48
|
+
format: 'trie-1.0',
|
|
49
|
+
sources: ['wordlist.tsv'],
|
|
50
|
+
// This is a possible word breaking function:
|
|
51
|
+
wordBreaker(phrase) {
|
|
52
|
+
return [];
|
|
53
|
+
}
|
|
54
|
+
}, PATH);
|
|
55
|
+
let result = compileModelSourceCode(code);
|
|
56
|
+
assert.isFalse(result.hasSyntaxError, `Syntax error in ${code}`);
|
|
57
|
+
assert.isNotNull(result.exportedModel);
|
|
58
|
+
assert.equal(result.modelConstructorName, 'TrieModel');
|
|
59
|
+
// Sanity check: the word breaker is a property of the object.
|
|
60
|
+
assert.match(code, /\bwordBreaker\b["']?:\s+function\b/);
|
|
61
|
+
});
|
|
62
|
+
it('should not generate unpaired surrogate code units', function () {
|
|
63
|
+
const MODEL_ID = 'example.qaa.smp';
|
|
64
|
+
const PATH = makePathToFixture(MODEL_ID);
|
|
65
|
+
let compiler = new LexicalModelCompiler;
|
|
66
|
+
let code = compiler.generateLexicalModelCode(MODEL_ID, {
|
|
67
|
+
format: 'trie-1.0',
|
|
68
|
+
sources: ['wordlist.tsv']
|
|
69
|
+
}, PATH);
|
|
70
|
+
let result = compileModelSourceCode(code);
|
|
71
|
+
assert.isFalse(result.hasSyntaxError);
|
|
72
|
+
assert.isNotNull(result.exportedModel);
|
|
73
|
+
assert.equal(result.modelConstructorName, 'TrieModel');
|
|
74
|
+
// Test every character in the string to make sure we don't have
|
|
75
|
+
// unpaired surrogates which destroy everything.
|
|
76
|
+
// We can assume that the first and last chars are not SMP
|
|
77
|
+
for (var i = 1; i < code.length - 1; i++) {
|
|
78
|
+
assert.notEqual(0xFFFD, code.charCodeAt(i));
|
|
79
|
+
if (code.charCodeAt(i) >= 0xD800 && code.charCodeAt(i) < 0xDC00) {
|
|
80
|
+
assert.isTrue((code.charCodeAt(i + 1) >= 0xDC00 && code.charCodeAt(i + 1) < 0xE000), 'Unpaired lead surrogate U+' + code.charCodeAt(i).toString(16) + ' at position ' + i + ' of \'' + code + '\'');
|
|
81
|
+
}
|
|
82
|
+
else if (code.charCodeAt(i) >= 0xDC00 && code.charCodeAt(i) < 0xE000) {
|
|
83
|
+
assert.isTrue((code.charCodeAt(i - 1) >= 0xD800 && code.charCodeAt(i - 1) < 0xDC00), 'Unpaired trail surrogate U+' + code.charCodeAt(i).toString(16) + ' at position ' + i + ' of \'' + code + '\'');
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
// Sanity check: the word list has three total unweighted words, with a
|
|
87
|
+
// total weight of 27,596!
|
|
88
|
+
assert.match(code, /\btotalWeight\b["']?:\s*27596\b/);
|
|
89
|
+
});
|
|
90
|
+
it('should include the source code of its search term to key function', function () {
|
|
91
|
+
const MODEL_ID = 'example.qaa.trivial';
|
|
92
|
+
const PATH = makePathToFixture(MODEL_ID);
|
|
93
|
+
let compiler = new LexicalModelCompiler;
|
|
94
|
+
let code = compiler.generateLexicalModelCode(MODEL_ID, {
|
|
95
|
+
format: 'trie-1.0',
|
|
96
|
+
sources: ['wordlist.tsv']
|
|
97
|
+
// NOTE: we intentionally OMIT the searchTermToKey function
|
|
98
|
+
// so that the default can be provided.
|
|
99
|
+
}, PATH);
|
|
100
|
+
assert.match(code, /(["']|)searchTermToKey\1:\s*function\b/, 'expected to find searchTermToKey specified as a function');
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
describe('createTrieDataStructure()', function () {
|
|
104
|
+
const WORDLIST_FILENAME = makePathToFixture('example.qaa.trivial', 'wordlist.tsv');
|
|
105
|
+
it('must be given an explicit searchTermToKey function', function () {
|
|
106
|
+
assert.throws(function () {
|
|
107
|
+
createTrieDataStructure([WORDLIST_FILENAME]);
|
|
108
|
+
}, TypeError);
|
|
109
|
+
});
|
|
110
|
+
it('uses the provided searchTermToKey function', function () {
|
|
111
|
+
// check if the expected key is in the resultant data structure.
|
|
112
|
+
// N.B., we assume the wordlist contains the wordform "turtles"
|
|
113
|
+
let lowercaseSourceCode = createTrieDataStructure([WORDLIST_FILENAME], (wf) => {
|
|
114
|
+
return wf.toLowerCase();
|
|
115
|
+
});
|
|
116
|
+
assert.match(lowercaseSourceCode, /"key":\s*"turtles"/);
|
|
117
|
+
assert.notMatch(lowercaseSourceCode, /"key":\s*"TURTLES"/);
|
|
118
|
+
let uppercaseSourceCode = createTrieDataStructure([WORDLIST_FILENAME], (wf) => {
|
|
119
|
+
return wf.toUpperCase();
|
|
120
|
+
});
|
|
121
|
+
assert.match(uppercaseSourceCode, /"key":\s*"TURTLES"/);
|
|
122
|
+
assert.notMatch(uppercaseSourceCode, /"key":\s*"turtles"/);
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
//# sourceMappingURL=test-compile-trie.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-compile-trie.js","sourceRoot":"","sources":["../../test/test-compile-trie.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAC,MAAM,EAAC,MAAM,MAAM,CAAC;AAC5B,OAAO,OAAO,CAAC;AAEf,OAAO,EAAC,iBAAiB,EAAE,sBAAsB,EAAC,MAAM,oBAAoB,CAAC;AAC7E,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAE/D,QAAQ,CAAC,sBAAsB,EAAE;IAC/B,QAAQ,CAAC,2BAA2B,EAAE;QACpC,EAAE,CAAC,oCAAoC,EAAE;YACvC,MAAM,QAAQ,GAAG,qBAAqB,CAAC;YACvC,MAAM,IAAI,GAAG,iBAAiB,CAAC,QAAQ,CAAC,CAAC;YAEzC,IAAI,QAAQ,GAAG,IAAI,oBAAoB,CAAC;YACxC,IAAI,IAAI,GAAG,QAAQ,CAAC,wBAAwB,CAAC,QAAQ,EAAE;gBACrD,MAAM,EAAE,UAAU;gBAClB,OAAO,EAAE,CAAC,cAAc,CAAC;aAC1B,EAAE,IAAI,CAAW,CAAC;YAEnB,IAAI,MAAM,GAAG,sBAAsB,CAAC,IAAI,CAAC,CAAC;YAC1C,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;YACtC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;YACvC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,oBAAoB,EAAE,WAAW,CAAC,CAAC;YAEvD,uEAAuE;YACvE,qBAAqB;YACrB,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,6BAA6B,CAAC,CAAC;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