-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.d.ts
More file actions
279 lines (270 loc) · 11 KB
/
Copy pathindex.d.ts
File metadata and controls
279 lines (270 loc) · 11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
/// <reference lib="esnext.disposable" />
import type {
DictionaryResource,
LatticeProvider,
LatticeProviderOptions,
LatticeResource,
RuntimeIdentity,
ScalarWfstProvider,
ScalarWfstProviderOptions,
SemiringOrder,
SemiringProperty,
SemiringProvider,
SemiringProviderOptions,
UnitDomain,
} from "@vinary-tree/vinary-tree-interop";
export type {
DictionaryResource,
LatticeOperand,
LatticeProvider,
LatticeProviderOptions,
LatticeResource,
ProviderDomainId,
Resource,
RuntimeIdentity,
ScalarWfstProvider,
ScalarWfstProviderOptions,
SemiringOrder,
SemiringProperty,
SemiringProvider,
SemiringProviderOptions,
UnitDomain,
WeightDomain as InteropWeightDomain,
WfstProviderArc,
WfstProviderArcPage,
WfstProviderStateInfo,
WfstResource,
} from "@vinary-tree/vinary-tree-interop";
export type Algorithm = "standard" | "transposition" | "merge-and-split" | "damerau-levenshtein";
export type QueryOrder = "traversal" | "distance-then-term";
export type DictionaryValue = bigint | null;
export type DictionaryKey = string | Uint8Array | BigUint64Array;
export type DictionaryEntry = readonly [DictionaryKey, DictionaryValue];
export type AlgebraOperation = "union" | "intersection" | "difference" | "symmetric-difference";
export type ValueMerge = "first" | "last" | "lattice-join" | "lattice-meet";
export interface Lookup { readonly found: boolean; readonly value: DictionaryValue; }
export type Term =
| { readonly domain: "unicode"; readonly value: string }
| { readonly domain: "byte"; readonly value: Uint8Array }
| { readonly domain: "u64"; readonly value: BigUint64Array };
export interface Match { readonly term: Term; readonly distance: number; readonly id: bigint | null; }
export interface DictionaryEntryCursor extends IterableIterator<DictionaryEntry> {
readonly size: number;
readonly identity: Readonly<{ producer: bigint; revision: bigint }> | null;
nextBatch(maximum: number): DictionaryEntry[];
reduceBatches<A>(
reducer: (accumulator: A, batch: readonly DictionaryEntry[]) => A,
initial: A,
batchSize?: number,
): A;
close(): void;
[Symbol.dispose](): void;
}
export interface Dictionary extends DictionaryResource, Iterable<DictionaryEntry> {
readonly size: number;
put(term: DictionaryKey, value?: DictionaryValue): boolean;
putU64(term: BigUint64Array, value?: DictionaryValue): boolean;
set(term: DictionaryKey, value?: DictionaryValue): this;
remove(term: DictionaryKey): boolean;
removeU64(term: BigUint64Array): boolean;
delete(term: DictionaryKey): boolean;
has(term: DictionaryKey): boolean;
hasU64(term: BigUint64Array): boolean;
lookup(term: DictionaryKey): Lookup;
lookupU64(term: BigUint64Array): Lookup;
get(term: DictionaryKey): DictionaryValue | undefined;
getU64(term: BigUint64Array): DictionaryValue | undefined;
snapshotEntries(): readonly DictionaryEntry[];
entries(): IterableIterator<DictionaryEntry>;
keys(): IterableIterator<DictionaryKey>;
values(): IterableIterator<DictionaryValue>;
streamEntries(): DictionaryEntryCursor;
algebra(right: Dictionary, operation: AlgebraOperation, valueMerge?: ValueMerge): Dictionary;
union(right: Dictionary, valueMerge?: ValueMerge): Dictionary;
intersection(right: Dictionary, valueMerge?: ValueMerge): Dictionary;
difference(right: Dictionary): Dictionary;
symmetricDifference(right: Dictionary): Dictionary;
forEach(callback: (value: DictionaryValue, key: DictionaryKey, dictionary: Dictionary) => void, thisArg?: unknown): void;
toMap(): Map<string, DictionaryValue>;
clear(): void;
compact(): number;
containsSubstring(term: string): boolean;
substringFrequency(term: string): number;
close(): void;
[Symbol.dispose](): void;
}
export interface QueryCursor extends IterableIterator<Match> {
nextBatch(maximum: number): Match[];
reduceBatches<A>(reducer: (accumulator: A, batch: readonly Match[]) => A, initial: A, batchSize?: number): A;
close(): void;
[Symbol.dispose](): void;
}
export interface AutomatonSize { readonly states: number; readonly transitions: number; }
export interface PhoneticPattern { readonly size: AutomatonSize; matches(input: string): boolean; close(): void; }
export interface PhoneticRuleSet { readonly size: number; apply(input: string): string; close(): void; }
export interface Transducer {
query(input: string, maximumDistance: number, order?: QueryOrder): QueryCursor;
query(input: Uint8Array | BigUint64Array | PhoneticPattern, maximumDistance: number): QueryCursor;
close(): void;
[Symbol.dispose](): void;
}
/** TinyLFU/SIEVE policy counters and current bounded residency. */
export interface QueryCacheStats {
readonly requests: bigint;
readonly hits: bigint;
readonly misses: bigint;
readonly admissions: bigint;
readonly rejections: bigint;
readonly evictions: bigint;
readonly residentEntries: number;
readonly residentWeight: number;
}
/** Hard bounds applied independently to each result-order cache shard. */
export interface QueryCacheOptions {
readonly maximumEntries?: number;
readonly maximumWeight?: number;
}
/** Exclusive, synchronization-free cache of complete snapshot query results. */
export interface QueryCache {
readonly stats: QueryCacheStats;
query(input: string, maximumDistance: number, order?: QueryOrder): QueryCursor;
query(input: Uint8Array | BigUint64Array, maximumDistance: number): QueryCursor;
clear(): this;
resetStats(): this;
close(): void;
[Symbol.dispose](): void;
}
export interface LibdictensteinNamespace {
readonly runtimeIdentity: RuntimeIdentity;
dynamicDawg(unitDomain?: UnitDomain): Dictionary;
doubleArrayTrie(entries: readonly { term: string; value?: DictionaryValue }[], unitDomain?: "byte" | "unicode"): Dictionary;
scdawg(unitDomain?: "byte" | "unicode"): Dictionary;
}
export interface LiblevenshteinNamespace {
readonly runtimeIdentity: RuntimeIdentity;
transducer(dictionary: DictionaryResource, algorithm?: Algorithm): Transducer;
queryCache(transducer: Transducer, options?: QueryCacheOptions): QueryCache;
phoneticPattern(source: string): PhoneticPattern;
llrePattern(source: string): PhoneticPattern;
phoneticRules(source: string): PhoneticRuleSet;
levenshteinDistance(source: string, target: string): number;
levenshteinDistanceThreshold(source: string, target: string, maximum: number): number | undefined;
damerauDistance(source: string, target: string): number;
damerauDistanceThreshold(source: string, target: string, maximum: number): number | undefined;
trueDamerauDistance(source: string, target: string): number;
trueDamerauDistanceThreshold(source: string, target: string, maximum: number): number | undefined;
}
export type WeightDomain =
| "tropical-f64" | "log-f64" | "probability-f64" | "arctic-f64"
| "signed-tropical-f64" | "count-f64" | "boolean-f64";
export interface WfstArc {
readonly input: string | number | bigint | null;
readonly output: string | number | bigint | null;
readonly target: bigint;
readonly weight: number;
}
export interface WfstState {
readonly valid: boolean;
readonly final: boolean;
readonly finalWeight: number;
readonly arcs: readonly WfstArc[];
}
export interface Wfst {
readonly interfaceId: "vt.scalar-wfst.1";
readonly runtimeIdentity: RuntimeIdentity;
readonly unitDomain: UnitDomain;
readonly weightDomain: WeightDomain;
start(): bigint;
state(state: bigint): WfstState;
close(): void;
[Symbol.dispose](): void;
}
export interface WfstBuilder {
addState(): number;
setStart(state: number): void;
setFinal(state: number, weight: number): void;
addArc(from: number, input: string | null, output: string | null, to: number, weight: number): void;
build(): Wfst;
close(): void;
[Symbol.dispose](): void;
}
export interface Lattice extends LatticeResource {
join(other: Lattice): Lattice;
meet(other: Lattice): Lattice;
equal(other: Lattice): boolean;
stableBytes(): Uint8Array;
diagnostic(): string;
joinMany(others: readonly Lattice[]): Lattice;
meetMany(others: readonly Lattice[]): Lattice;
close(): void;
[Symbol.dispose](): void;
}
export interface SemiringWeight {
readonly interfaceId: "vt.semiring.val1";
readonly runtimeIdentity: RuntimeIdentity;
readonly domainId: string;
clone(): SemiringWeight;
stableBytes(): Uint8Array;
diagnostic(): string;
close(): void;
[Symbol.dispose](): void;
}
export interface Semiring {
readonly interfaceId: "vt.semiring.ctx1";
readonly runtimeIdentity: RuntimeIdentity;
readonly domainId: string;
readonly properties: readonly SemiringProperty[];
zero(): SemiringWeight;
one(): SemiringWeight;
plus(left: SemiringWeight, right: SemiringWeight): SemiringWeight;
times(left: SemiringWeight, right: SemiringWeight): SemiringWeight;
equal(left: SemiringWeight, right: SemiringWeight): boolean;
approximatelyEqual(left: SemiringWeight, right: SemiringWeight, epsilon: number): boolean;
naturalOrder(left: SemiringWeight, right: SemiringWeight): SemiringOrder;
stableBytes(value: SemiringWeight): Uint8Array;
diagnostic(value?: SemiringWeight | null): string;
plusMany(values: readonly SemiringWeight[]): SemiringWeight;
timesMany(values: readonly SemiringWeight[]): SemiringWeight;
divide(dividend: SemiringWeight, divisor: SemiringWeight): SemiringWeight | null;
leftDivide(value: SemiringWeight, divisor: SemiringWeight): SemiringWeight | null;
star(value: SemiringWeight): SemiringWeight | null;
numericalValue(value: SemiringWeight): number;
quantize(value: SemiringWeight, epsilon: number): bigint;
toProbability(value: SemiringWeight): number;
closureBound(): bigint | null;
validateLaws(values: readonly SemiringWeight[], epsilon?: number): void;
close(): void;
[Symbol.dispose](): void;
}
export interface LlingLlangNamespace {
readonly runtimeIdentity: RuntimeIdentity;
vectorWfst(): WfstBuilder;
lattice(provider: LatticeProvider, options: LatticeProviderOptions): Lattice;
validateLatticeLaws(values: readonly Lattice[]): void;
semiring(provider: SemiringProvider, options: SemiringProviderOptions): Semiring;
scalarWfst(provider: ScalarWfstProvider, options?: ScalarWfstProviderOptions): Wfst;
compose(first: Wfst, second: Wfst): Wfst;
}
export type DuallityWfstKind =
| "levenshtein"
| "universal-standard" | "universal-transposition" | "universal-merge-and-split"
| "generalized-standard" | "generalized-transposition"
| "generalized-merge-and-split" | "generalized-phonetic" | "fzf";
export interface DuallityNamespace {
readonly runtimeIdentity: RuntimeIdentity;
wfst(dictionary: DictionaryResource, query: string, maximumDistance: number,
algorithm?: Algorithm, kind?: DuallityWfstKind): Wfst;
}
export const runtimeIdentity: RuntimeIdentity;
export const libdictenstein: LibdictensteinNamespace;
export const liblevenshtein: LiblevenshteinNamespace;
export const llingLlang: LlingLlangNamespace;
export const duallity: DuallityNamespace;
declare const runtime: {
readonly runtimeIdentity: RuntimeIdentity;
readonly libdictenstein: LibdictensteinNamespace;
readonly liblevenshtein: LiblevenshteinNamespace;
readonly llingLlang: LlingLlangNamespace;
readonly duallity: DuallityNamespace;
};
export default runtime;