mirror of
https://github.com/keymanapp/keyman.git
synced 2026-10-25 07:17:41 +00:00
change(web): establish unitTestEndpoints for worker-thread
This commit is contained in:
parent
1b40d3a3ba
commit
5fad61d606
5 changed files with 24 additions and 7 deletions
|
|
@ -210,7 +210,7 @@ export interface SearchQuotientNode {
|
|||
* @param keystrokeDistributions
|
||||
* @internal
|
||||
*/
|
||||
export function quotientPathHasInputs(node: SearchQuotientNode, keystrokeDistributions: Distribution<Transform>[]): boolean {
|
||||
function quotientPathHasInputs(node: SearchQuotientNode, keystrokeDistributions: Distribution<Transform>[]): boolean {
|
||||
if(!(node instanceof SearchQuotientSpur)) {
|
||||
for(const p of node.parents) {
|
||||
if(quotientPathHasInputs(p, keystrokeDistributions)) {
|
||||
|
|
@ -274,7 +274,7 @@ export function quotientPathHasInputs(node: SearchQuotientNode, keystrokeDistrib
|
|||
*
|
||||
* Intended only for use during unit testing. Does not include the root node.
|
||||
*/
|
||||
export function constituentPaths(node: SearchQuotientNode): SearchQuotientSpur[][] {
|
||||
function constituentPaths(node: SearchQuotientNode): SearchQuotientSpur[][] {
|
||||
if(node instanceof SearchQuotientRoot) {
|
||||
return [];
|
||||
} else if(node instanceof SearchQuotientSpur) {
|
||||
|
|
@ -290,4 +290,9 @@ export function constituentPaths(node: SearchQuotientNode): SearchQuotientSpur[]
|
|||
} else {
|
||||
throw new Error("constituentPaths is unable to handle a new, unexpected SearchQuotientNode type");
|
||||
}
|
||||
}
|
||||
|
||||
export const unitTestEndpoints = {
|
||||
quotientPathHasInputs,
|
||||
constituentPaths
|
||||
}
|
||||
|
|
@ -20,4 +20,10 @@ export { ModelCompositor } from './model-compositor.js';
|
|||
export * from './predict-helpers.js';
|
||||
export { default as TransformUtils } from './transformUtils.js'
|
||||
export { default as LMLayerWorker } from './index.js'
|
||||
export * from './transform-subsets.js';
|
||||
export * from './transform-subsets.js';
|
||||
|
||||
// unitTestEndpoints
|
||||
import { unitTestEndpoints as SearchQuotientNodeEndpoints } from './correction/search-quotient-node.js';
|
||||
export const unitTestEndpoints: typeof SearchQuotientNodeEndpoints = {
|
||||
...SearchQuotientNodeEndpoints
|
||||
}
|
||||
|
|
@ -13,14 +13,16 @@ import { assert } from 'chai';
|
|||
import { default as defaultBreaker } from '@keymanapp/models-wordbreakers';
|
||||
import { jsonFixture } from '@keymanapp/common-test-resources/model-helpers.mjs';
|
||||
import { LexicalModelTypes } from '@keymanapp/common-types';
|
||||
import { KMWString } from '@keymanapp/web-utils';
|
||||
|
||||
import { ContextToken, correction, generateSubsetId, getBestMatches, models, preprocessInputSources, quotientPathHasInputs, SearchQuotientSpur } from '@keymanapp/lm-worker/test-index';
|
||||
import { ContextToken, correction, generateSubsetId, getBestMatches, models, preprocessInputSources, SearchQuotientSpur, unitTestEndpoints } from '@keymanapp/lm-worker/test-index';
|
||||
|
||||
import Distribution = LexicalModelTypes.Distribution;
|
||||
import ExecutionTimer = correction.ExecutionTimer;
|
||||
import Transform = LexicalModelTypes.Transform;
|
||||
import TrieModel = models.TrieModel;
|
||||
import { KMWString } from '@keymanapp/web-utils';
|
||||
|
||||
const { quotientPathHasInputs } = unitTestEndpoints;
|
||||
|
||||
var plainModel = new TrieModel(jsonFixture('models/tries/english-1000'),
|
||||
{wordBreaker: defaultBreaker});
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
import { assert } from 'chai';
|
||||
|
||||
import { jsonFixture } from '@keymanapp/common-test-resources/model-helpers.mjs';
|
||||
import { LegacyQuotientRoot, models, quotientPathHasInputs } from '@keymanapp/lm-worker/test-index';
|
||||
import { LegacyQuotientRoot, models, unitTestEndpoints } from '@keymanapp/lm-worker/test-index';
|
||||
|
||||
import { buildSimplePathSplitFixture } from './search-quotient-spur.tests.js';
|
||||
|
||||
const { quotientPathHasInputs } = unitTestEndpoints;
|
||||
|
||||
import TrieModel = models.TrieModel;
|
||||
|
||||
const testModel = new TrieModel(jsonFixture('models/tries/english-1000'));
|
||||
|
|
|
|||
|
|
@ -10,10 +10,12 @@
|
|||
import { assert } from 'chai';
|
||||
|
||||
import { jsonFixture } from '@keymanapp/common-test-resources/model-helpers.mjs';
|
||||
import { LegacyQuotientSpur, models, LegacyQuotientRoot, quotientPathHasInputs, constituentPaths } from '@keymanapp/lm-worker/test-index';
|
||||
import { LegacyQuotientSpur, models, LegacyQuotientRoot, unitTestEndpoints } from '@keymanapp/lm-worker/test-index';
|
||||
|
||||
import TrieModel = models.TrieModel;
|
||||
|
||||
const { constituentPaths, quotientPathHasInputs } = unitTestEndpoints;
|
||||
|
||||
const testModel = new TrieModel(jsonFixture('models/tries/english-1000'));
|
||||
|
||||
export function buildSimplePathSplitFixture() {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue