-
Notifications
You must be signed in to change notification settings - Fork 7
/
cldAsmModule.ts
98 lines (93 loc) · 3.05 KB
/
cldAsmModule.ts
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
export const UnknownLanguage: string = 'und';
export interface LanguageResult {
/**
* Detected language. {UnknownLanguage} if detection fails.
*/
language: string;
/**
* Language probability.
*/
probability: number;
/**
* Whether the prediction is reliable.
*/
is_reliable: boolean;
/**
* Proportion of bytes associated with the language. If FindLanguage is
* called, this variable is set to 1.
*/
proportion: number;
}
/**
* @internal
*/
export interface ResultVector {
size(): number;
get(index: number): LanguageResult;
}
/**
* @internal
*/
export interface NNetLanguageIdentifier {
/**
* Finds the most likely language for the given text, along with additional
* information (e.g., probability). The prediction is based on the first N
* bytes where N is the minumum between the number of interchange valid UTF8
* bytes and max_num_bytes_. If N is less than min_num_bytes_ long, then this
* function returns kUnknown.
*/
FindLanguage(text: string): LanguageResult;
/**
* Splits the input text (up to the first byte, if any, that is not
* interchange valid UTF8) into spans based on the script, predicts a language
* for each span, and returns a vector storing the top num_langs most frequent
* languages along with additional information (e.g., proportions). The number
* of bytes considered for each span is the minimum between the size of the
* span and max_num_bytes_. If more languages are requested than what is
* available in the input, then for those cases kUnknown is returned. Also, if
* the size of the span is less than min_num_bytes_ long, then the span is
* skipped. If the input text is too long, only the first
* kMaxNumInputBytesToConsider bytes are processed.
*/
FindTopNMostFreqLangs(text: string, numLangs: number): ResultVector;
/**
* Destroy instance of identifier
*/
delete(): void;
}
/**
* @internal
*
* Interface for module generated by emscripten to load wasm binary.
* https://kripken.github.io/emscripten-site/docs/api_reference/preamble.js.html
*/
export interface CldAsmModule {
NNetLanguageIdentifier: {
/**
* Min number of bytes needed to make a prediction if the default constructor
* is called.
*/
kMinNumBytesToConsider: number;
/**
* Max number of bytes to consider to make a prediction if the default
* constructor is called.
*/
kMaxNumBytesToConsider: number;
/**
* Max number of input bytes to process.
*/
kMaxNumInputBytesToConsider: number;
/**
* Predictions with probability greater than or equal to this threshold are
* marked as reliable. This threshold was optimized on a set of text segments
* extracted from wikipedia, and results in an overall precision, recall,
* and f1 equal to 0.9760, 0.9624, and 0.9692, respectively.
*/
kReliabilityThreshold: number;
/**
* Reliability threshold for the languages hr and bs.
*/
kReliabilityHrBsThreshold: number;
new (minBytes: number, maxBytes: number): NNetLanguageIdentifier;
};
}