mirror of
https://github.com/keymanapp/keyman.git
synced 2026-08-07 17:36:00 +00:00
change(web): Apply suggestions from code review
Co-authored-by: Marc Durdin <marc@durdin.net>
This commit is contained in:
parent
ab52938d96
commit
b544aeff37
1 changed files with 13 additions and 20 deletions
|
|
@ -1,3 +1,11 @@
|
|||
/*
|
||||
* Keyman is copyright (C) SIL Global. MIT License.
|
||||
*
|
||||
* Created by jahorton on 2025-07-30
|
||||
*
|
||||
* Represents cached data about one token (either a word or a unit of whitespace)
|
||||
* in the context and associated correction-search progress and results.
|
||||
*/
|
||||
import { buildMergedTransform } from "@keymanapp/models-templates";
|
||||
import { SearchSpace } from "./distance-modeler.js";
|
||||
import { KMWString } from "@keymanapp/web-utils";
|
||||
|
|
@ -19,26 +27,11 @@ import Transform = LexicalModelTypes.Transform;
|
|||
* @param transformId
|
||||
* @returns
|
||||
*/
|
||||
function textToCharTransforms(text: string, transformId?: number) {
|
||||
let perCharTransforms: Transform[] = [];
|
||||
|
||||
for(let i=0; i < KMWString.length(text); i++) {
|
||||
let char = KMWString.charAt(text, i); // is SMP-aware
|
||||
|
||||
let transform: Transform = {
|
||||
insert: char,
|
||||
deleteLeft: 0
|
||||
};
|
||||
|
||||
if(transformId) {
|
||||
transform.id = transformId
|
||||
}
|
||||
|
||||
perCharTransforms.push(transform);
|
||||
}
|
||||
|
||||
return perCharTransforms;
|
||||
}
|
||||
function textToCharTransforms(text: string, transformId?: number): Transform[] {
|
||||
return transformId ?
|
||||
[...text].map(insert => ({insert, deleteLeft: 0, id: transformId})) :
|
||||
[...text].map(insert => ({insert, deleteLeft: 0}));
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents cached data about one token (either a word or a unit of whitespace)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue