@frontierrnd/translation-consistency 0.0.0-stage → 1.2.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Frontier R&D
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,97 @@
1
- # Temporary Holding Version
1
+ # `@frontierrnd/translation-consistency`
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Sub-millisecond, zero-pretraining, script-blind **translation consistency & anomaly detection** powered by **relational geometry (`FastIso v1.2`)**, written in Rust and compiled to WebAssembly.
4
+
5
+ Score draft translations, flag likely human edits, pick the best candidate (`FastIso + MBR` consensus + CPU glossary swaps), localize anomalous spans, and audit passage-level drift in **Browser Web Workers, Node.js, Tauri, or Edge runtimes** — using only the source text and the project's own checked translations.
6
+
7
+ - **Zero pretrained weights & zero GPU:** Works on any language or script (Latin, Syriac, vocalized Arabic, Indic, indigenous languages) via Unicode `L|M|N` tokenization and diacritic-stripped root skeletons.
8
+ - **Tiny footprint:** ~203 KB gzipped `.wasm`, ~7–15 MB RAM per project (`indexCap = 1000`), `< 1.0 ms/candidate` scoring.
9
+ - **Explicit versioning with `"latest"` default:** Pin a version (`"1.2"`) for reproducible evaluations or omit it to track `"latest"`. Every score and serialized binary cache stamps its exact `engineVersion`.
10
+
11
+ ---
12
+
13
+ ## Install
14
+
15
+ ```bash
16
+ npm install @frontierrnd/translation-consistency
17
+ ```
18
+
19
+ ## Quick Start
20
+
21
+ ```ts
22
+ import {
23
+ createScorer,
24
+ deserializeScorer,
25
+ peekSerializedVersion,
26
+ } from "@frontierrnd/translation-consistency";
27
+
28
+ // 1. Fit once from your project's validated translations (defaults to version: "latest")
29
+ const scorer = await createScorer(validatedPairs, {
30
+ version: "latest", // or pin "1.2"
31
+ indexCap: 1000, // sub-ms sweet spot for echo & LM index
32
+ maxLexicalPairs: 12000,
33
+ });
34
+
35
+ // 2. Score a batch of LLM drafts (~0.35–1.0 ms/candidate)
36
+ const scores = scorer.scoreBatch(sourceText, drafts);
37
+ // scores[i] -> { engineVersion: "1.2.0", total, residual, diagnostics, ... }
38
+
39
+ // 3. Pick Best-of-N with Soft FastIso + MBR consensus + zero-LLM CPU glossary swaps
40
+ const winner = scorer.pickBest(sourceText, drafts, {
41
+ isoWeight: 0.45,
42
+ glossarySwap: true,
43
+ stitch: false,
44
+ });
45
+
46
+ // 4. Cache the compiled index in IndexedDB / disk
47
+ const blob = scorer.serialize();
48
+ const cached = await deserializeScorer(blob, { version: "latest" });
49
+ // Returns `null` if `blob` was built with an older engine version -> trigger clean rebuild!
50
+
51
+ scorer.dispose();
52
+ ```
53
+
54
+ ### Cloudflare Workers / Custom WASM Loading
55
+
56
+ In browsers (Vite/Webpack/Web Workers) and Node.js, WASM loads automatically. In environments that disallow dynamic `fetch`/`fs` (like Cloudflare Workers), initialize once with the static WASM export:
57
+
58
+ ```ts
59
+ import { initWasm, createScorer } from "@frontierrnd/translation-consistency";
60
+ import wasmModule from "@frontierrnd/translation-consistency/wasm";
61
+
62
+ await initWasm(wasmModule);
63
+ const scorer = await createScorer(validatedPairs);
64
+ ```
65
+
66
+ ---
67
+
68
+ ## API Overview
69
+
70
+ | Export / Method | What it does |
71
+ |---|---|
72
+ | `createScorer(pairs, opts?)` | Fits `FastIso` (`version: "latest"` default, or `"1.2"`). |
73
+ | `deserializeScorer(bytes, opts?)` | Restores a serialized index; returns `null` on version mismatch unless `{ strict: true }`. |
74
+ | `peekSerializedVersion(bytes)` | Reads the stamped `engineVersion` header without decoding the index. |
75
+ | `scorer.score(src, cand)` / `scoreBatch(src, cands)` | Returns 5-channel `ScoreBreakdown`, source-difficulty `residual` (for cross-verse routing), and plain-English `diagnostics`. |
76
+ | `scorer.pickBest(src, cands, opts?)` | Soft `FastIso + MBR` reranker with optional monotonic CPU glossary swaps and multi-draft lattice stitching. |
77
+ | `scorer.extractGlossary(src, opts?)` | High-confidence project term hints + chapter locks. |
78
+ | `scorer.localizeSpans(src, cand, maxWindow?)` | Batched LOSO span anomaly localization, Doppler-foreign token flags, missing project terms, and `safeMaskedTemplate` (never masks rare correct OOV words). |
79
+ | `scorer.scanPassageDrift(srcs, tgts)` | Contiguous-passage audit: 3-verse sliding windows, adjacent-verse `transitionIso`, and intra-passage terminology splits. |
80
+ | `chrfPP(hyp, ref)` | Pure-WASM sentence-level `chrF++` (char 1–6 + word 1–2, `beta = 2.0`). |
81
+
82
+ ---
83
+
84
+ ## Development
85
+
86
+ ```bash
87
+ npm install
88
+ npm test # Runs Rust unit + Python golden parity tests, builds WASM + TS, runs Node WASM tests
89
+ npm run build # Builds dist/wasm + dist/*.js + dist/*.d.ts
90
+ ```
91
+
92
+ ### Repository Layout
93
+
94
+ - `crates/fast-iso-core` — Native Rust crate (usable directly in Tauri or Rust CLIs; verified against `fixtures/golden_v12.json`).
95
+ - `crates/fast-iso-wasm` — `wasm-bindgen` bridge.
96
+ - `js/src` — TypeScript ergonomic wrapper and cross-runtime WASM loader.
97
+ - `fixtures/golden_v12.json` — Golden parity fixture generated directly from Python `fast_iso_v12.py`.
@@ -0,0 +1,183 @@
1
+ import { initWasm, type WasmInitInput } from "./wasm-loader.js";
2
+ import type { WasmFastIso } from "./wasm/fast_iso_wasm.js";
3
+ export { initWasm, type WasmInitInput };
4
+ /** Current default engine version resolved by `"latest"`. */
5
+ export declare const LATEST_VERSION: "1.2.0";
6
+ /** All version selectors accepted by `createScorer` and `deserializeScorer`. */
7
+ export declare const SUPPORTED_VERSIONS: readonly ["latest", "1.2", "1.2.0"];
8
+ export type VersionSelector = (typeof SUPPORTED_VERSIONS)[number] | (string & {});
9
+ export interface ParallelPair {
10
+ source: string;
11
+ target: string;
12
+ }
13
+ export interface FitOptions {
14
+ /** Engine version to use. Defaults to `"latest"` (`"1.2.0"`). Pin e.g. `"1.2"` for reproducible evals. */
15
+ version?: VersionSelector;
16
+ /** Run out-of-fold per-project calibration and 5-feature Ridge source-difficulty residualizer. Default: `true`. */
17
+ fitCal?: boolean;
18
+ /** Max held-out rows used for OOF calibration. Default: `120`. */
19
+ maxCal?: number;
20
+ /** Max rows kept in the TF-IDF echo & LM index (sweet spot: `1000`, `< 1.6 ms/cand`). Set `null` to disable cap. */
21
+ indexCap?: number | null;
22
+ /** Max corpus pairs used for full-corpus subword/stem IBM1 alignment. Default: `12000`. */
23
+ maxLexicalPairs?: number;
24
+ }
25
+ export interface DeserializeOptions {
26
+ /** Expected engine version. Defaults to `"latest"`. */
27
+ version?: VersionSelector;
28
+ /**
29
+ * If `false` (default), returns `null` when a cached blob was built by a different engine version
30
+ * so callers can cleanly rebuild in a background worker.
31
+ * If `true`, throws on version mismatch.
32
+ */
33
+ strict?: boolean;
34
+ }
35
+ export interface ScoreBreakdown {
36
+ engineVersion: string;
37
+ total: number;
38
+ residual: number;
39
+ isoProfile: number;
40
+ bidiEcho: number;
41
+ lexicalCons: number;
42
+ entityGuard: number;
43
+ halfOrder: number;
44
+ infoMass: number;
45
+ fluencyFloor: number;
46
+ clonePenalty: number;
47
+ repPenalty: number;
48
+ sourceMaxIdf: number;
49
+ diagnostics: string[];
50
+ }
51
+ export interface PickBestOptions {
52
+ /** Weight on FastIso z-score vs. MBR consensus z-score (0..1). Default: `0.45`. */
53
+ isoWeight?: number;
54
+ /** Enable multi-draft CPU lattice span stitching. Default: `false`. */
55
+ stitch?: boolean;
56
+ /** Enable zero-LLM-call monotonic CPU glossary swap for Doppler-foreign tokens. Default: `true`. */
57
+ glossarySwap?: boolean;
58
+ /** Max greedy CPU edits when `stitch` or `glossarySwap` is enabled. Default: `3`. */
59
+ maxEdits?: number;
60
+ /** Minimum donor draft support for lattice span proposals. Default: `2`. */
61
+ minSupport?: number;
62
+ }
63
+ export interface CandidateRank {
64
+ index: number;
65
+ text: string;
66
+ combinedScore: number;
67
+ mbrScore: number;
68
+ breakdown: ScoreBreakdown;
69
+ }
70
+ export interface PickBestResult {
71
+ engineVersion: string;
72
+ bestText: string;
73
+ bestIndex: number;
74
+ editsApplied: number;
75
+ finalBreakdown: ScoreBreakdown;
76
+ ranked: CandidateRank[];
77
+ }
78
+ export interface GlossaryOptions {
79
+ maxTerms?: number;
80
+ minDf?: number;
81
+ minProb?: number;
82
+ passageLocks?: Record<string, string>;
83
+ }
84
+ export interface GlossaryTarget {
85
+ term: string;
86
+ prob: number;
87
+ }
88
+ export interface GlossaryHint {
89
+ sourceTerm: string;
90
+ targets: GlossaryTarget[];
91
+ idf: number;
92
+ locked: boolean;
93
+ }
94
+ export interface TokenFlag {
95
+ tokenIndex: number;
96
+ token: string;
97
+ score: number;
98
+ }
99
+ export interface MissingTerm {
100
+ sourceTerm: string;
101
+ expectedTarget: string;
102
+ }
103
+ export interface SpanAnomalyReport {
104
+ engineVersion: string;
105
+ baseScore: number;
106
+ worstSpanIdx: [number, number] | null;
107
+ worstSpanText: string;
108
+ worstSpanGain: number;
109
+ maskedTemplate: string;
110
+ /** Safe Doppler-only mask template (only masks verified foreign tokens, never rare OOV nouns). */
111
+ safeMaskedTemplate: string | null;
112
+ missingTerms: MissingTerm[];
113
+ foreignTokens: TokenFlag[];
114
+ seamSpikes: TokenFlag[];
115
+ }
116
+ export interface TermSplit {
117
+ sourceWord: string;
118
+ dominantTarget: string;
119
+ formCounts: Record<string, number>;
120
+ verseIndices: number[];
121
+ missingIndices: number[];
122
+ }
123
+ export interface SeamGap {
124
+ leftIndex: number;
125
+ rightIndex: number;
126
+ gap: number;
127
+ }
128
+ export interface PassageDriftReport {
129
+ engineVersion: string;
130
+ meanVerseIso: number;
131
+ meanWin3Iso: number;
132
+ transitionIso: number;
133
+ termConsistencyRate: number;
134
+ termSplits: TermSplit[];
135
+ flaggedVerses: number[];
136
+ verseIsoScores: number[];
137
+ worstSeams: SeamGap[];
138
+ }
139
+ export declare class FastIsoScorer {
140
+ #private;
141
+ /** @internal */
142
+ constructor(inner: WasmFastIso);
143
+ /** Concrete semantic version of the engine backing this scorer (e.g. `"1.2.0"`). */
144
+ get engineVersion(): string;
145
+ /** Number of rows indexed in the TF-IDF / LM index (capped by `indexCap`). */
146
+ get corpusSize(): number;
147
+ /** Number of full-corpus rows available to the subword/stem IBM1 aligner. */
148
+ get lexicalSize(): number;
149
+ /** Score a single `(source, candidate)` pair. */
150
+ score(source: string, candidate: string): ScoreBreakdown;
151
+ /** Score a batch of candidate translations against one source string (~1 ms/candidate). */
152
+ scoreBatch(source: string, candidates: string[]): ScoreBreakdown[];
153
+ /**
154
+ * Pick the best candidate from a pool using Soft `FastIso + MBR` consensus,
155
+ * with optional monotonic CPU glossary swaps and multi-draft lattice stitching.
156
+ */
157
+ pickBest(source: string, candidates: string[], options?: PickBestOptions): PickBestResult;
158
+ /** Extract high-confidence project glossary hints for content words in `source`. */
159
+ extractGlossary(source: string, options?: GlossaryOptions): GlossaryHint[];
160
+ /** Localize anomalous 1–2 token spans, Doppler-foreign words, and missing project terms. */
161
+ localizeSpans(source: string, candidate: string, maxWindow?: number): SpanAnomalyReport;
162
+ /** Audit macro passage-level coherence: 3-verse windows, transition isomorphism, and term splits. */
163
+ scanPassageDrift(sources: string[], targets: string[]): PassageDriftReport;
164
+ /** Serialize the compiled scorer into a compact version-stamped binary blob for IndexedDB/disk caching. */
165
+ serialize(): Uint8Array;
166
+ /** Free the underlying WebAssembly memory immediately. */
167
+ dispose(): void;
168
+ }
169
+ /**
170
+ * Fit a new `FastIsoScorer` from validated parallel project pairs.
171
+ * Defaults to `version: "latest"` (`1.2.0`).
172
+ */
173
+ export declare function createScorer(pairs: ParallelPair[], options?: FitOptions): Promise<FastIsoScorer>;
174
+ /**
175
+ * Restore a cached `FastIsoScorer` from `serialize()` bytes.
176
+ * Returns `null` (unless `strict: true`) if the blob was built with an older/different engine version.
177
+ */
178
+ export declare function deserializeScorer(bytes: Uint8Array, options?: DeserializeOptions): Promise<FastIsoScorer | null>;
179
+ /** Read the engine version stamped in a serialized blob without decoding the index. */
180
+ export declare function peekSerializedVersion(bytes: Uint8Array): Promise<string>;
181
+ /** Pure-WASM sentence-level `chrF++` (char 1–6 + word 1–2, beta=2.0), returning 0..100. */
182
+ export declare function chrfPP(hypothesis: string, reference: string): Promise<number>;
183
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../js/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D,OAAO,EAAE,QAAQ,EAAE,KAAK,aAAa,EAAE,CAAC;AAExC,6DAA6D;AAC7D,eAAO,MAAM,cAAc,EAAG,OAAgB,CAAC;AAE/C,gFAAgF;AAChF,eAAO,MAAM,kBAAkB,qCAAsC,CAAC;AAEtE,MAAM,MAAM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@@ -0,0 +1,211 @@
1
+ import { initWasm } from "./wasm-loader.js";
2
+ export { initWasm };
3
+ /** Current default engine version resolved by `"latest"`. */
4
+ export const LATEST_VERSION = "1.2.0";
5
+ /** All version selectors accepted by `createScorer` and `deserializeScorer`. */
6
+ export const SUPPORTED_VERSIONS = ["latest", "1.2", "1.2.0"];
7
+ function mapBreakdown(raw) {
8
+ return {
9
+ engineVersion: raw.engine_version,
10
+ total: raw.total,
11
+ residual: raw.residual,
12
+ isoProfile: raw.iso_profile,
13
+ bidiEcho: raw.bidi_echo,
14
+ lexicalCons: raw.lexical_cons,
15
+ entityGuard: raw.entity_guard,
16
+ halfOrder: raw.half_order,
17
+ infoMass: raw.info_mass,
18
+ fluencyFloor: raw.fluency_floor,
19
+ clonePenalty: raw.clone_penalty,
20
+ repPenalty: raw.rep_penalty,
21
+ sourceMaxIdf: raw.source_max_idf,
22
+ diagnostics: raw.diagnostics ?? [],
23
+ };
24
+ }
25
+ function mapToRecord(val) {
26
+ if (val instanceof Map) {
27
+ const out = {};
28
+ for (const [k, v] of val.entries())
29
+ out[String(k)] = Number(v);
30
+ return out;
31
+ }
32
+ return val ?? {};
33
+ }
34
+ export class FastIsoScorer {
35
+ #inner;
36
+ /** @internal */
37
+ constructor(inner) {
38
+ this.#inner = inner;
39
+ }
40
+ #get() {
41
+ if (!this.#inner) {
42
+ throw new Error("FastIsoScorer has been disposed");
43
+ }
44
+ return this.#inner;
45
+ }
46
+ /** Concrete semantic version of the engine backing this scorer (e.g. `"1.2.0"`). */
47
+ get engineVersion() {
48
+ return this.#get().engineVersion;
49
+ }
50
+ /** Number of rows indexed in the TF-IDF / LM index (capped by `indexCap`). */
51
+ get corpusSize() {
52
+ return this.#get().corpusSize;
53
+ }
54
+ /** Number of full-corpus rows available to the subword/stem IBM1 aligner. */
55
+ get lexicalSize() {
56
+ return this.#get().lexicalSize;
57
+ }
58
+ /** Score a single `(source, candidate)` pair. */
59
+ score(source, candidate) {
60
+ return this.scoreBatch(source, [candidate])[0];
61
+ }
62
+ /** Score a batch of candidate translations against one source string (~1 ms/candidate). */
63
+ scoreBatch(source, candidates) {
64
+ const raw = this.#get().scoreBatch(source, candidates);
65
+ return raw.map(mapBreakdown);
66
+ }
67
+ /**
68
+ * Pick the best candidate from a pool using Soft `FastIso + MBR` consensus,
69
+ * with optional monotonic CPU glossary swaps and multi-draft lattice stitching.
70
+ */
71
+ pickBest(source, candidates, options = {}) {
72
+ const raw = this.#get().pickBest(source, candidates, options);
73
+ return {
74
+ engineVersion: raw.engine_version,
75
+ bestText: raw.best_text,
76
+ bestIndex: raw.best_index,
77
+ editsApplied: raw.edits_applied,
78
+ finalBreakdown: mapBreakdown(raw.final_breakdown),
79
+ ranked: (raw.ranked ?? []).map((r) => ({
80
+ index: r.index,
81
+ text: r.text,
82
+ combinedScore: r.combined_score,
83
+ mbrScore: r.mbr_score,
84
+ breakdown: mapBreakdown(r.breakdown),
85
+ })),
86
+ };
87
+ }
88
+ /** Extract high-confidence project glossary hints for content words in `source`. */
89
+ extractGlossary(source, options = {}) {
90
+ const raw = this.#get().extractGlossary(source, options);
91
+ return raw.map((h) => ({
92
+ sourceTerm: h.source_term,
93
+ targets: (h.targets ?? []).map((t) => ({
94
+ term: t.term,
95
+ prob: t.prob,
96
+ })),
97
+ idf: h.idf,
98
+ locked: Boolean(h.locked),
99
+ }));
100
+ }
101
+ /** Localize anomalous 1–2 token spans, Doppler-foreign words, and missing project terms. */
102
+ localizeSpans(source, candidate, maxWindow = 2) {
103
+ const raw = this.#get().localizeSpans(source, candidate, maxWindow);
104
+ return {
105
+ engineVersion: raw.engine_version,
106
+ baseScore: raw.base_score,
107
+ worstSpanIdx: raw.worst_span_idx ?? null,
108
+ worstSpanText: raw.worst_span_text,
109
+ worstSpanGain: raw.worst_span_gain,
110
+ maskedTemplate: raw.masked_template,
111
+ safeMaskedTemplate: raw.safe_masked_template ?? null,
112
+ missingTerms: (raw.missing_terms ?? []).map((m) => ({
113
+ sourceTerm: m.source_term,
114
+ expectedTarget: m.expected_target,
115
+ })),
116
+ foreignTokens: (raw.foreign_tokens ?? []).map((f) => ({
117
+ tokenIndex: f.token_index,
118
+ token: f.token,
119
+ score: f.score,
120
+ })),
121
+ seamSpikes: (raw.seam_spikes ?? []).map((s) => ({
122
+ tokenIndex: s.token_index,
123
+ token: s.token,
124
+ score: s.score,
125
+ })),
126
+ };
127
+ }
128
+ /** Audit macro passage-level coherence: 3-verse windows, transition isomorphism, and term splits. */
129
+ scanPassageDrift(sources, targets) {
130
+ const raw = this.#get().scanPassageDrift(sources, targets);
131
+ return {
132
+ engineVersion: raw.engine_version,
133
+ meanVerseIso: raw.mean_verse_iso,
134
+ meanWin3Iso: raw.mean_win3_iso,
135
+ transitionIso: raw.transition_iso,
136
+ termConsistencyRate: raw.term_consistency_rate,
137
+ termSplits: (raw.term_splits ?? []).map((ts) => ({
138
+ sourceWord: ts.source_word,
139
+ dominantTarget: ts.dominant_target,
140
+ formCounts: mapToRecord(ts.form_counts),
141
+ verseIndices: ts.verse_indices ?? [],
142
+ missingIndices: ts.missing_indices ?? [],
143
+ })),
144
+ flaggedVerses: raw.flagged_verses ?? [],
145
+ verseIsoScores: raw.verse_iso_scores ?? [],
146
+ worstSeams: (raw.worst_seams ?? []).map((s) => ({
147
+ leftIndex: s.left_index,
148
+ rightIndex: s.right_index,
149
+ gap: s.gap,
150
+ })),
151
+ };
152
+ }
153
+ /** Serialize the compiled scorer into a compact version-stamped binary blob for IndexedDB/disk caching. */
154
+ serialize() {
155
+ return this.#get().serialize();
156
+ }
157
+ /** Free the underlying WebAssembly memory immediately. */
158
+ dispose() {
159
+ if (this.#inner) {
160
+ this.#inner.free();
161
+ this.#inner = null;
162
+ }
163
+ }
164
+ }
165
+ /**
166
+ * Fit a new `FastIsoScorer` from validated parallel project pairs.
167
+ * Defaults to `version: "latest"` (`1.2.0`).
168
+ */
169
+ export async function createScorer(pairs, options = {}) {
170
+ const mod = await initWasm();
171
+ const wasmOpts = {
172
+ version: options.version ?? "latest",
173
+ fitCal: options.fitCal,
174
+ maxCal: options.maxCal,
175
+ indexCap: options.indexCap === null ? undefined : options.indexCap,
176
+ disableIndexCap: options.indexCap === null,
177
+ maxLexicalPairs: options.maxLexicalPairs,
178
+ };
179
+ const inner = new mod.WasmFastIso(pairs, wasmOpts);
180
+ return new FastIsoScorer(inner);
181
+ }
182
+ /**
183
+ * Restore a cached `FastIsoScorer` from `serialize()` bytes.
184
+ * Returns `null` (unless `strict: true`) if the blob was built with an older/different engine version.
185
+ */
186
+ export async function deserializeScorer(bytes, options = {}) {
187
+ const mod = await initWasm();
188
+ const version = options.version ?? "latest";
189
+ try {
190
+ const inner = mod.WasmFastIso.deserialize(bytes, version);
191
+ return new FastIsoScorer(inner);
192
+ }
193
+ catch (err) {
194
+ const msg = String(err);
195
+ if (!options.strict && msg.includes("version mismatch")) {
196
+ return null;
197
+ }
198
+ throw err;
199
+ }
200
+ }
201
+ /** Read the engine version stamped in a serialized blob without decoding the index. */
202
+ export async function peekSerializedVersion(bytes) {
203
+ const mod = await initWasm();
204
+ return mod.peekSerializedVersion(bytes);
205
+ }
206
+ /** Pure-WASM sentence-level `chrF++` (char 1–6 + word 1–2, beta=2.0), returning 0..100. */
207
+ export async function chrfPP(hypothesis, reference) {
208
+ const mod = await initWasm();
209
+ return mod.chrfPP(hypothesis, reference);
210
+ }
211
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../js/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAsB,MAAM,kBAAkB,CAAC;AAGhE,OAAO,EAAE,QAAQ,EAAsB,CAAC;AAExC,6DAA6D;AAC7D,MAAM,CAAC,MAAM,cAAc,GAAG,OAAgB,CAAC;AAE/C,gFAAgF;AAChF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,QAAQ,EAAE,KAAK,EAAE,OAAO,CAAU,CAAC;AAsJtE,SAAS,YAAY,CAA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,MAAM,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;AAC3C,CAAC"}
@@ -0,0 +1,78 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ export class WasmFastIso {
5
+ free(): void;
6
+ [Symbol.dispose](): void;
7
+ static deserialize(bytes: Uint8Array | number[], version?: string | null): WasmFastIso;
8
+ extractGlossary(source: string, options_js: any): any;
9
+ constructor(pairs_js: any, options_js: any);
10
+ localizeSpans(source: string, candidate: string, max_window?: number | null): any;
11
+ pickBest(source: string, candidates_js: any, options_js: any): any;
12
+ scanPassageDrift(sources_js: any, targets_js: any): any;
13
+ scoreBatch(source: string, candidates_js: any): any;
14
+ serialize(): Uint8Array;
15
+ readonly corpusSize: number;
16
+ readonly engineVersion: string;
17
+ readonly lexicalSize: number;
18
+ }
19
+
20
+ export function chrfPP(hyp: string, reference: string): number;
21
+
22
+ export function latestVersion(): string;
23
+
24
+ export function peekSerializedVersion(bytes: Uint8Array | number[]): string;
25
+
26
+ export function supportedVersions(): any;
27
+
28
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
29
+
30
+ export interface InitOutput {
31
+ readonly memory: WebAssembly.Memory;
32
+ readonly __wbg_wasmfastiso_free: (a: number, b: number) => void;
33
+ readonly chrfPP: (a: number, b: number, c: number, d: number) => number;
34
+ readonly latestVersion: () => [number, number];
35
+ readonly peekSerializedVersion: (a: number, b: number) => [number, number, number, number];
36
+ readonly supportedVersions: () => any;
37
+ readonly wasmfastiso_corpusSize: (a: number) => number;
38
+ readonly wasmfastiso_deserialize: (a: number, b: number, c: number, d: number) => [number, number, number];
39
+ readonly wasmfastiso_engineVersion: (a: number) => [number, number];
40
+ readonly wasmfastiso_extractGlossary: (a: number, b: number, c: number, d: any) => [number, number, number];
41
+ readonly wasmfastiso_fit: (a: any, b: any) => [number, number, number];
42
+ readonly wasmfastiso_lexicalSize: (a: number) => number;
43
+ readonly wasmfastiso_localizeSpans: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
44
+ readonly wasmfastiso_pickBest: (a: number, b: number, c: number, d: any, e: any) => [number, number, number];
45
+ readonly wasmfastiso_scanPassageDrift: (a: number, b: any, c: any) => [number, number, number];
46
+ readonly wasmfastiso_scoreBatch: (a: number, b: number, c: number, d: any) => [number, number, number];
47
+ readonly wasmfastiso_serialize: (a: number) => [number, number, number, number];
48
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
49
+ readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
50
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
51
+ readonly __wbindgen_exn_store: (a: number) => void;
52
+ readonly __externref_table_alloc: () => number;
53
+ readonly __wbindgen_externrefs: WebAssembly.Table;
54
+ readonly __externref_table_dealloc: (a: number) => void;
55
+ readonly __wbindgen_start: () => void;
56
+ }
57
+
58
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
59
+
60
+ /**
61
+ * Instantiates the given `module`, which can either be bytes or
62
+ * a precompiled `WebAssembly.Module`.
63
+ *
64
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
65
+ *
66
+ * @returns {InitOutput}
67
+ */
68
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
69
+
70
+ /**
71
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
72
+ * for everything else, calls `WebAssembly.instantiate` directly.
73
+ *
74
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
75
+ *
76
+ * @returns {Promise<InitOutput>}
77
+ */
78
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;