rita 3.0.23 → 3.0.26
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/dist/rita.cjs +25 -10
- package/dist/rita.cjs.map +1 -1
- package/dist/rita.d.cts +253 -0
- package/dist/rita.d.ts +253 -0
- package/dist/rita.js +25 -10
- package/dist/rita.js.map +1 -1
- package/dist/rita.min.js +61 -61
- package/dist/rita.min.js.map +1 -1
- package/package.json +12 -8
package/dist/rita.d.cts
ADDED
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
export class RiTa {
|
|
2
|
+
static grammar(rules?: object, context?: object): any;
|
|
3
|
+
static addTransform(name: string, definition: object): void;
|
|
4
|
+
static removeTransform(name: string): void;
|
|
5
|
+
static getTransforms(): string[];
|
|
6
|
+
static articlize(word: string): string;
|
|
7
|
+
static evaluate(script: string, context?: object, options?: {
|
|
8
|
+
trace?: boolean;
|
|
9
|
+
}): string;
|
|
10
|
+
static markov(n: number, options?: {
|
|
11
|
+
text?: string | string[];
|
|
12
|
+
maxLengthMatch?: number;
|
|
13
|
+
maxAttempts?: number;
|
|
14
|
+
tokenize?: object;
|
|
15
|
+
untokenize?: object;
|
|
16
|
+
disableInputChecks?: boolean;
|
|
17
|
+
trace?: boolean;
|
|
18
|
+
}): RiMarkov;
|
|
19
|
+
static kwic(keyword: string, options?: {
|
|
20
|
+
numWords?: number;
|
|
21
|
+
text?: string;
|
|
22
|
+
words?: string[];
|
|
23
|
+
}): string[];
|
|
24
|
+
static kwic(keyword: string, text: number): string[];
|
|
25
|
+
static concordance(text: string, options?: {
|
|
26
|
+
ignoreCase?: boolean;
|
|
27
|
+
ignoreStopWords?: boolean;
|
|
28
|
+
ignorePunctuation?: boolean;
|
|
29
|
+
wordsToIgnore?: string[];
|
|
30
|
+
}): object;
|
|
31
|
+
static randomOrdering(array: object[]): object[];
|
|
32
|
+
static randomOrdering(k: number): number[];
|
|
33
|
+
static randomSeed(seed: number): void;
|
|
34
|
+
static isQuestion(sentence: string): boolean;
|
|
35
|
+
static isVowel(char: string): boolean;
|
|
36
|
+
static isConsonant(char: string): boolean;
|
|
37
|
+
static capitalize(string: string): string;
|
|
38
|
+
static randomWord(pattern?: string | RegExp, options?: {
|
|
39
|
+
minLength?: number;
|
|
40
|
+
maxLength?: number;
|
|
41
|
+
numSyllables?: number;
|
|
42
|
+
limit?: number;
|
|
43
|
+
pos?: string;
|
|
44
|
+
pattern?: RegExp;
|
|
45
|
+
type?: string;
|
|
46
|
+
}): string;
|
|
47
|
+
static rhymes(word: string, options?: {
|
|
48
|
+
minLength?: number;
|
|
49
|
+
maxLength?: number;
|
|
50
|
+
numSyllables?: number;
|
|
51
|
+
limit?: number;
|
|
52
|
+
shuffle?: boolean;
|
|
53
|
+
pos?: string;
|
|
54
|
+
}): Promise<string[]>;
|
|
55
|
+
static isRhyme(word1: string, word2: string): boolean;
|
|
56
|
+
static alliterations(word: string, options?: {
|
|
57
|
+
minLength?: number;
|
|
58
|
+
maxLength?: number;
|
|
59
|
+
numSyllables?: number;
|
|
60
|
+
limit?: number;
|
|
61
|
+
shuffle?: boolean;
|
|
62
|
+
pos?: string;
|
|
63
|
+
}): Promise<string[]>;
|
|
64
|
+
static hasWord(word: string, options?: {
|
|
65
|
+
noDerivations?: boolean;
|
|
66
|
+
}): boolean;
|
|
67
|
+
static isAbbrev(input: string, options?: {
|
|
68
|
+
caseSensitive?: boolean;
|
|
69
|
+
}): boolean;
|
|
70
|
+
static isAlliteration(word1: string, word2: string): boolean;
|
|
71
|
+
static spellsLike(word: string, options?: {
|
|
72
|
+
minLength?: number;
|
|
73
|
+
maxLength?: number;
|
|
74
|
+
numSyllables?: number;
|
|
75
|
+
limit?: number;
|
|
76
|
+
shuffle?: boolean;
|
|
77
|
+
pos?: string;
|
|
78
|
+
}): Promise<string[]>;
|
|
79
|
+
static soundsLike(word: string, options?: {
|
|
80
|
+
minLength?: number;
|
|
81
|
+
maxLength?: number;
|
|
82
|
+
numSyllables?: number;
|
|
83
|
+
limit?: number;
|
|
84
|
+
shuffle?: boolean;
|
|
85
|
+
matchSpelling?: boolean;
|
|
86
|
+
pos?: string;
|
|
87
|
+
}): Promise<string[]>;
|
|
88
|
+
static pos(word: string | string[], options?: {
|
|
89
|
+
simple?: boolean;
|
|
90
|
+
}): string | string[];
|
|
91
|
+
static isNoun(word: string): string;
|
|
92
|
+
static isAdjective(word: string): string;
|
|
93
|
+
static isAdverb(word: string): string;
|
|
94
|
+
static isVerb(word: string): string;
|
|
95
|
+
static isPunct(text: string): boolean;
|
|
96
|
+
static posInline(sentence: string, options?: {
|
|
97
|
+
simple?: boolean;
|
|
98
|
+
}): string;
|
|
99
|
+
static singularize(word: string): string;
|
|
100
|
+
static pluralize(word: string): string;
|
|
101
|
+
static search(pattern?: string | RegExp, options?: {
|
|
102
|
+
minLength?: number;
|
|
103
|
+
maxLength?: number;
|
|
104
|
+
numSyllables?: number;
|
|
105
|
+
limit?: number;
|
|
106
|
+
shuffle?: boolean;
|
|
107
|
+
pos?: string;
|
|
108
|
+
type?: string;
|
|
109
|
+
}): Promise<string[]>;
|
|
110
|
+
static tokens(text: string, options?: {
|
|
111
|
+
caseSensitive?: boolean;
|
|
112
|
+
ignoreStopWords?: boolean;
|
|
113
|
+
splitContractions?: boolean;
|
|
114
|
+
includePunct?: boolean;
|
|
115
|
+
sort?: boolean;
|
|
116
|
+
}): string[];
|
|
117
|
+
static tokenize(input: string, options?: {
|
|
118
|
+
regex?: RegExp;
|
|
119
|
+
splitHyphens?: boolean;
|
|
120
|
+
splitContractions?: boolean;
|
|
121
|
+
}): string[];
|
|
122
|
+
static untokenize(input: string[], delim?: string): string;
|
|
123
|
+
static sentences(text: string, pattern?: string | RegExp): string[];
|
|
124
|
+
static isStopWord(word: string): boolean;
|
|
125
|
+
static stem(word: string): string;
|
|
126
|
+
static presentPart(verbWord: string): string;
|
|
127
|
+
static pastPart(verbWord: string): string;
|
|
128
|
+
static conjugate(verbWord: string, options?: {
|
|
129
|
+
tense?: number;
|
|
130
|
+
person?: number;
|
|
131
|
+
number?: number;
|
|
132
|
+
form?: number;
|
|
133
|
+
passive?: boolean;
|
|
134
|
+
progressive?: boolean;
|
|
135
|
+
perfect?: boolean;
|
|
136
|
+
interrogative?: boolean;
|
|
137
|
+
}): string;
|
|
138
|
+
static stresses(input: string, options?: object): string;
|
|
139
|
+
static syllables(input: string, options?: object): string;
|
|
140
|
+
static phones(input: string, options?: object): string;
|
|
141
|
+
static analyze(input: string, options?: {
|
|
142
|
+
simple?: boolean;
|
|
143
|
+
}): object;
|
|
144
|
+
static spellsLikeSync(word: string, options?: {
|
|
145
|
+
minLength?: number;
|
|
146
|
+
maxLength?: number;
|
|
147
|
+
numSyllables?: number;
|
|
148
|
+
limit?: number;
|
|
149
|
+
pos?: string;
|
|
150
|
+
shuffle?: boolean;
|
|
151
|
+
}): string[];
|
|
152
|
+
static soundsLikeSync(word: string, options?: {
|
|
153
|
+
minLength?: number;
|
|
154
|
+
maxLength?: number;
|
|
155
|
+
numSyllables?: number;
|
|
156
|
+
limit?: number;
|
|
157
|
+
matchSpelling?: boolean;
|
|
158
|
+
shuffle?: boolean;
|
|
159
|
+
pos?: string;
|
|
160
|
+
}): string[];
|
|
161
|
+
static rhymesSync(word: string, options?: {
|
|
162
|
+
minLength?: number;
|
|
163
|
+
maxLength?: number;
|
|
164
|
+
numSyllables?: number;
|
|
165
|
+
limit?: number;
|
|
166
|
+
shuffle?: boolean;
|
|
167
|
+
pos?: string;
|
|
168
|
+
}): string[];
|
|
169
|
+
static searchSync(pattern?: string | RegExp, options?: {
|
|
170
|
+
minLength?: number;
|
|
171
|
+
maxLength?: number;
|
|
172
|
+
numSyllables?: number;
|
|
173
|
+
limit?: number;
|
|
174
|
+
shuffle?: boolean;
|
|
175
|
+
pos?: string;
|
|
176
|
+
type?: string;
|
|
177
|
+
}): string[];
|
|
178
|
+
static alliterationsSync(word: string, options?: {
|
|
179
|
+
minLength?: number;
|
|
180
|
+
maxLength?: number;
|
|
181
|
+
numSyllables?: number;
|
|
182
|
+
limit?: number;
|
|
183
|
+
shuffle?: boolean;
|
|
184
|
+
pos?: string;
|
|
185
|
+
}): string[];
|
|
186
|
+
static randi(param1: number, param2?: number): number;
|
|
187
|
+
static random(param1?: number | object[], param2?: number): number | object;
|
|
188
|
+
|
|
189
|
+
static VERSION: string;
|
|
190
|
+
static SILENT: boolean;
|
|
191
|
+
static SILENCE_LTS: boolean;
|
|
192
|
+
static SPLIT_CONTRACTIONS: boolean;
|
|
193
|
+
|
|
194
|
+
static STRESS: string;
|
|
195
|
+
static NOSTRESS: string;
|
|
196
|
+
static PHONE_BOUNDARY: string;
|
|
197
|
+
static WORD_BOUNDARY: string;
|
|
198
|
+
static SYLLABLE_BOUNDARY: string;
|
|
199
|
+
static SENTENCE_BOUNDARY: string;
|
|
200
|
+
static VOWELS: string;
|
|
201
|
+
static PHONES: string[];
|
|
202
|
+
static ABRV: string[];
|
|
203
|
+
static QUESTIONS: string[];
|
|
204
|
+
static STOP_WORDS: string[];
|
|
205
|
+
static MASS_NOUNS: string[];
|
|
206
|
+
|
|
207
|
+
static INFINITIVE: number;
|
|
208
|
+
static FIRST: number;
|
|
209
|
+
static SECOND: number;
|
|
210
|
+
static THIRD: number;
|
|
211
|
+
static PAST: number;
|
|
212
|
+
static PRESENT: number;
|
|
213
|
+
static FUTURE: number;
|
|
214
|
+
static SINGULAR: number;
|
|
215
|
+
static PLURAL: number;
|
|
216
|
+
static NORMAL: number;
|
|
217
|
+
static GERUND: number;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export class RiMarkov {
|
|
221
|
+
static fromJSON(json: string): RiMarkov;
|
|
222
|
+
constructor(n?: number, options?: {
|
|
223
|
+
text?: string | string[];
|
|
224
|
+
trace?: boolean;
|
|
225
|
+
maxLengthMatch?: number;
|
|
226
|
+
maxAttempts?: number;
|
|
227
|
+
tokenizer?: object;
|
|
228
|
+
untokenizer?: object;
|
|
229
|
+
disableInputChecks?: boolean;
|
|
230
|
+
});
|
|
231
|
+
n: number;
|
|
232
|
+
addText(text: string | string[], multiplier?: number): RiMarkov;
|
|
233
|
+
generate(count: number, options?: {
|
|
234
|
+
minLength?: number;
|
|
235
|
+
maxLength?: number;
|
|
236
|
+
temperature?: number;
|
|
237
|
+
allowDuplicates?: boolean;
|
|
238
|
+
seed?: string | string[];
|
|
239
|
+
}): string[];
|
|
240
|
+
generate(options?: {
|
|
241
|
+
minLength?: number;
|
|
242
|
+
maxLength?: number;
|
|
243
|
+
temperature?: number;
|
|
244
|
+
allowDuplicates?: boolean;
|
|
245
|
+
seed?: string | string[];
|
|
246
|
+
}): string;
|
|
247
|
+
toJSON(): string;
|
|
248
|
+
completions(pre: string[], post?: string[]): string[];
|
|
249
|
+
probabilities(path: string | string[], temperature?: number): object;
|
|
250
|
+
probability(data: string | string[]): number;
|
|
251
|
+
toString(root: object, sort: boolean): string;
|
|
252
|
+
size(): number;
|
|
253
|
+
}
|
package/dist/rita.d.ts
ADDED
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
export class RiTa {
|
|
2
|
+
static grammar(rules?: object, context?: object): any;
|
|
3
|
+
static addTransform(name: string, definition: object): void;
|
|
4
|
+
static removeTransform(name: string): void;
|
|
5
|
+
static getTransforms(): string[];
|
|
6
|
+
static articlize(word: string): string;
|
|
7
|
+
static evaluate(script: string, context?: object, options?: {
|
|
8
|
+
trace?: boolean;
|
|
9
|
+
}): string;
|
|
10
|
+
static markov(n: number, options?: {
|
|
11
|
+
text?: string | string[];
|
|
12
|
+
maxLengthMatch?: number;
|
|
13
|
+
maxAttempts?: number;
|
|
14
|
+
tokenize?: object;
|
|
15
|
+
untokenize?: object;
|
|
16
|
+
disableInputChecks?: boolean;
|
|
17
|
+
trace?: boolean;
|
|
18
|
+
}): RiMarkov;
|
|
19
|
+
static kwic(keyword: string, options?: {
|
|
20
|
+
numWords?: number;
|
|
21
|
+
text?: string;
|
|
22
|
+
words?: string[];
|
|
23
|
+
}): string[];
|
|
24
|
+
static kwic(keyword: string, text: number): string[];
|
|
25
|
+
static concordance(text: string, options?: {
|
|
26
|
+
ignoreCase?: boolean;
|
|
27
|
+
ignoreStopWords?: boolean;
|
|
28
|
+
ignorePunctuation?: boolean;
|
|
29
|
+
wordsToIgnore?: string[];
|
|
30
|
+
}): object;
|
|
31
|
+
static randomOrdering(array: object[]): object[];
|
|
32
|
+
static randomOrdering(k: number): number[];
|
|
33
|
+
static randomSeed(seed: number): void;
|
|
34
|
+
static isQuestion(sentence: string): boolean;
|
|
35
|
+
static isVowel(char: string): boolean;
|
|
36
|
+
static isConsonant(char: string): boolean;
|
|
37
|
+
static capitalize(string: string): string;
|
|
38
|
+
static randomWord(pattern?: string | RegExp, options?: {
|
|
39
|
+
minLength?: number;
|
|
40
|
+
maxLength?: number;
|
|
41
|
+
numSyllables?: number;
|
|
42
|
+
limit?: number;
|
|
43
|
+
pos?: string;
|
|
44
|
+
pattern?: RegExp;
|
|
45
|
+
type?: string;
|
|
46
|
+
}): string;
|
|
47
|
+
static rhymes(word: string, options?: {
|
|
48
|
+
minLength?: number;
|
|
49
|
+
maxLength?: number;
|
|
50
|
+
numSyllables?: number;
|
|
51
|
+
limit?: number;
|
|
52
|
+
shuffle?: boolean;
|
|
53
|
+
pos?: string;
|
|
54
|
+
}): Promise<string[]>;
|
|
55
|
+
static isRhyme(word1: string, word2: string): boolean;
|
|
56
|
+
static alliterations(word: string, options?: {
|
|
57
|
+
minLength?: number;
|
|
58
|
+
maxLength?: number;
|
|
59
|
+
numSyllables?: number;
|
|
60
|
+
limit?: number;
|
|
61
|
+
shuffle?: boolean;
|
|
62
|
+
pos?: string;
|
|
63
|
+
}): Promise<string[]>;
|
|
64
|
+
static hasWord(word: string, options?: {
|
|
65
|
+
noDerivations?: boolean;
|
|
66
|
+
}): boolean;
|
|
67
|
+
static isAbbrev(input: string, options?: {
|
|
68
|
+
caseSensitive?: boolean;
|
|
69
|
+
}): boolean;
|
|
70
|
+
static isAlliteration(word1: string, word2: string): boolean;
|
|
71
|
+
static spellsLike(word: string, options?: {
|
|
72
|
+
minLength?: number;
|
|
73
|
+
maxLength?: number;
|
|
74
|
+
numSyllables?: number;
|
|
75
|
+
limit?: number;
|
|
76
|
+
shuffle?: boolean;
|
|
77
|
+
pos?: string;
|
|
78
|
+
}): Promise<string[]>;
|
|
79
|
+
static soundsLike(word: string, options?: {
|
|
80
|
+
minLength?: number;
|
|
81
|
+
maxLength?: number;
|
|
82
|
+
numSyllables?: number;
|
|
83
|
+
limit?: number;
|
|
84
|
+
shuffle?: boolean;
|
|
85
|
+
matchSpelling?: boolean;
|
|
86
|
+
pos?: string;
|
|
87
|
+
}): Promise<string[]>;
|
|
88
|
+
static pos(word: string | string[], options?: {
|
|
89
|
+
simple?: boolean;
|
|
90
|
+
}): string | string[];
|
|
91
|
+
static isNoun(word: string): string;
|
|
92
|
+
static isAdjective(word: string): string;
|
|
93
|
+
static isAdverb(word: string): string;
|
|
94
|
+
static isVerb(word: string): string;
|
|
95
|
+
static isPunct(text: string): boolean;
|
|
96
|
+
static posInline(sentence: string, options?: {
|
|
97
|
+
simple?: boolean;
|
|
98
|
+
}): string;
|
|
99
|
+
static singularize(word: string): string;
|
|
100
|
+
static pluralize(word: string): string;
|
|
101
|
+
static search(pattern?: string | RegExp, options?: {
|
|
102
|
+
minLength?: number;
|
|
103
|
+
maxLength?: number;
|
|
104
|
+
numSyllables?: number;
|
|
105
|
+
limit?: number;
|
|
106
|
+
shuffle?: boolean;
|
|
107
|
+
pos?: string;
|
|
108
|
+
type?: string;
|
|
109
|
+
}): Promise<string[]>;
|
|
110
|
+
static tokens(text: string, options?: {
|
|
111
|
+
caseSensitive?: boolean;
|
|
112
|
+
ignoreStopWords?: boolean;
|
|
113
|
+
splitContractions?: boolean;
|
|
114
|
+
includePunct?: boolean;
|
|
115
|
+
sort?: boolean;
|
|
116
|
+
}): string[];
|
|
117
|
+
static tokenize(input: string, options?: {
|
|
118
|
+
regex?: RegExp;
|
|
119
|
+
splitHyphens?: boolean;
|
|
120
|
+
splitContractions?: boolean;
|
|
121
|
+
}): string[];
|
|
122
|
+
static untokenize(input: string[], delim?: string): string;
|
|
123
|
+
static sentences(text: string, pattern?: string | RegExp): string[];
|
|
124
|
+
static isStopWord(word: string): boolean;
|
|
125
|
+
static stem(word: string): string;
|
|
126
|
+
static presentPart(verbWord: string): string;
|
|
127
|
+
static pastPart(verbWord: string): string;
|
|
128
|
+
static conjugate(verbWord: string, options?: {
|
|
129
|
+
tense?: number;
|
|
130
|
+
person?: number;
|
|
131
|
+
number?: number;
|
|
132
|
+
form?: number;
|
|
133
|
+
passive?: boolean;
|
|
134
|
+
progressive?: boolean;
|
|
135
|
+
perfect?: boolean;
|
|
136
|
+
interrogative?: boolean;
|
|
137
|
+
}): string;
|
|
138
|
+
static stresses(input: string, options?: object): string;
|
|
139
|
+
static syllables(input: string, options?: object): string;
|
|
140
|
+
static phones(input: string, options?: object): string;
|
|
141
|
+
static analyze(input: string, options?: {
|
|
142
|
+
simple?: boolean;
|
|
143
|
+
}): object;
|
|
144
|
+
static spellsLikeSync(word: string, options?: {
|
|
145
|
+
minLength?: number;
|
|
146
|
+
maxLength?: number;
|
|
147
|
+
numSyllables?: number;
|
|
148
|
+
limit?: number;
|
|
149
|
+
pos?: string;
|
|
150
|
+
shuffle?: boolean;
|
|
151
|
+
}): string[];
|
|
152
|
+
static soundsLikeSync(word: string, options?: {
|
|
153
|
+
minLength?: number;
|
|
154
|
+
maxLength?: number;
|
|
155
|
+
numSyllables?: number;
|
|
156
|
+
limit?: number;
|
|
157
|
+
matchSpelling?: boolean;
|
|
158
|
+
shuffle?: boolean;
|
|
159
|
+
pos?: string;
|
|
160
|
+
}): string[];
|
|
161
|
+
static rhymesSync(word: string, options?: {
|
|
162
|
+
minLength?: number;
|
|
163
|
+
maxLength?: number;
|
|
164
|
+
numSyllables?: number;
|
|
165
|
+
limit?: number;
|
|
166
|
+
shuffle?: boolean;
|
|
167
|
+
pos?: string;
|
|
168
|
+
}): string[];
|
|
169
|
+
static searchSync(pattern?: string | RegExp, options?: {
|
|
170
|
+
minLength?: number;
|
|
171
|
+
maxLength?: number;
|
|
172
|
+
numSyllables?: number;
|
|
173
|
+
limit?: number;
|
|
174
|
+
shuffle?: boolean;
|
|
175
|
+
pos?: string;
|
|
176
|
+
type?: string;
|
|
177
|
+
}): string[];
|
|
178
|
+
static alliterationsSync(word: string, options?: {
|
|
179
|
+
minLength?: number;
|
|
180
|
+
maxLength?: number;
|
|
181
|
+
numSyllables?: number;
|
|
182
|
+
limit?: number;
|
|
183
|
+
shuffle?: boolean;
|
|
184
|
+
pos?: string;
|
|
185
|
+
}): string[];
|
|
186
|
+
static randi(param1: number, param2?: number): number;
|
|
187
|
+
static random(param1?: number | object[], param2?: number): number | object;
|
|
188
|
+
|
|
189
|
+
static VERSION: string;
|
|
190
|
+
static SILENT: boolean;
|
|
191
|
+
static SILENCE_LTS: boolean;
|
|
192
|
+
static SPLIT_CONTRACTIONS: boolean;
|
|
193
|
+
|
|
194
|
+
static STRESS: string;
|
|
195
|
+
static NOSTRESS: string;
|
|
196
|
+
static PHONE_BOUNDARY: string;
|
|
197
|
+
static WORD_BOUNDARY: string;
|
|
198
|
+
static SYLLABLE_BOUNDARY: string;
|
|
199
|
+
static SENTENCE_BOUNDARY: string;
|
|
200
|
+
static VOWELS: string;
|
|
201
|
+
static PHONES: string[];
|
|
202
|
+
static ABRV: string[];
|
|
203
|
+
static QUESTIONS: string[];
|
|
204
|
+
static STOP_WORDS: string[];
|
|
205
|
+
static MASS_NOUNS: string[];
|
|
206
|
+
|
|
207
|
+
static INFINITIVE: number;
|
|
208
|
+
static FIRST: number;
|
|
209
|
+
static SECOND: number;
|
|
210
|
+
static THIRD: number;
|
|
211
|
+
static PAST: number;
|
|
212
|
+
static PRESENT: number;
|
|
213
|
+
static FUTURE: number;
|
|
214
|
+
static SINGULAR: number;
|
|
215
|
+
static PLURAL: number;
|
|
216
|
+
static NORMAL: number;
|
|
217
|
+
static GERUND: number;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export class RiMarkov {
|
|
221
|
+
static fromJSON(json: string): RiMarkov;
|
|
222
|
+
constructor(n?: number, options?: {
|
|
223
|
+
text?: string | string[];
|
|
224
|
+
trace?: boolean;
|
|
225
|
+
maxLengthMatch?: number;
|
|
226
|
+
maxAttempts?: number;
|
|
227
|
+
tokenizer?: object;
|
|
228
|
+
untokenizer?: object;
|
|
229
|
+
disableInputChecks?: boolean;
|
|
230
|
+
});
|
|
231
|
+
n: number;
|
|
232
|
+
addText(text: string | string[], multiplier?: number): RiMarkov;
|
|
233
|
+
generate(count: number, options?: {
|
|
234
|
+
minLength?: number;
|
|
235
|
+
maxLength?: number;
|
|
236
|
+
temperature?: number;
|
|
237
|
+
allowDuplicates?: boolean;
|
|
238
|
+
seed?: string | string[];
|
|
239
|
+
}): string[];
|
|
240
|
+
generate(options?: {
|
|
241
|
+
minLength?: number;
|
|
242
|
+
maxLength?: number;
|
|
243
|
+
temperature?: number;
|
|
244
|
+
allowDuplicates?: boolean;
|
|
245
|
+
seed?: string | string[];
|
|
246
|
+
}): string;
|
|
247
|
+
toJSON(): string;
|
|
248
|
+
completions(pre: string[], post?: string[]): string[];
|
|
249
|
+
probabilities(path: string | string[], temperature?: number): object;
|
|
250
|
+
probability(data: string | string[]): number;
|
|
251
|
+
toString(root: object, sort: boolean): string;
|
|
252
|
+
size(): number;
|
|
253
|
+
}
|
package/dist/rita.js
CHANGED
|
@@ -41933,8 +41933,8 @@ var _RiMarkov = class _RiMarkov {
|
|
|
41933
41933
|
* @param {boolean} [options.trace] - output trace info to the console
|
|
41934
41934
|
* @param {number} [options.maxLengthMatch] - # of words allowed in result to match a sequence in the input, default=∞
|
|
41935
41935
|
* @param {number} [options.maxAttempts=999] - max attempts before to complete one ore more generations before erroring, default=999
|
|
41936
|
-
* @param {
|
|
41937
|
-
* @param {function} [options.untokenize] - custom
|
|
41936
|
+
* @param {object} [options.tokenize] - custom tokenize() function, defaults to RiTa.tokenize()
|
|
41937
|
+
* @param {function} [options.untokenize] - custom untokenize() function, defaults to RiTa.untokenize()
|
|
41938
41938
|
* @param {boolean} [options.disableInputChecks=false] - if true, allow result to be present in the input, default
|
|
41939
41939
|
* @memberof RiMarkov
|
|
41940
41940
|
*/
|
|
@@ -41967,7 +41967,7 @@ var _RiMarkov = class _RiMarkov {
|
|
|
41967
41967
|
*/
|
|
41968
41968
|
addText(text, multiplier = 1) {
|
|
41969
41969
|
let sents = Array.isArray(text) ? text : _RiMarkov.parent.sentences(text);
|
|
41970
|
-
let
|
|
41970
|
+
let allWords = [];
|
|
41971
41971
|
for (let k = 0; k < multiplier; k++) {
|
|
41972
41972
|
for (let i = 0; i < sents.length; i++) {
|
|
41973
41973
|
let words = this.tokenize(sents[i]);
|
|
@@ -41984,19 +41984,34 @@ var _RiMarkov = class _RiMarkov {
|
|
|
41984
41984
|
}
|
|
41985
41985
|
return this;
|
|
41986
41986
|
}
|
|
41987
|
-
/**
|
|
41988
|
-
*
|
|
41989
|
-
* @param {number}
|
|
41987
|
+
/**
|
|
41988
|
+
* @overload
|
|
41989
|
+
* @param {number} count
|
|
41990
41990
|
* @param {object} [options={}] - options for the generation
|
|
41991
41991
|
* @param {number} [options.minLength=5] - minimum length of each sentence
|
|
41992
41992
|
* @param {number} [options.maxLength=35] - maximum length of each sentence
|
|
41993
41993
|
* @param {number} [options.temperature=1] - temperature acts as a knob to adjust the probability that input elements will be selected for the output. At higher values, infrequent words are more likely to be chosen, while at lower values the most frequent inputs are more likely to be output. If no value is provided, then tokens are chosen according to their relative frequency in the input.
|
|
41994
41994
|
* @param {boolean} [options.allowDuplicates=false] - if true, allow duplicate sentences in the output
|
|
41995
41995
|
* @param {string|string[]} [options.seed] - a seed string or array of tokens to start the generation
|
|
41996
|
-
* @
|
|
41997
|
-
*
|
|
41996
|
+
* @returns {string[]}
|
|
41997
|
+
*
|
|
41998
|
+
* @overload
|
|
41999
|
+
* @param {object} [options={}] - options for the generation
|
|
42000
|
+
* @param {number} [options.minLength=5] - minimum length of each sentence
|
|
42001
|
+
* @param {number} [options.maxLength=35] - maximum length of each sentence
|
|
42002
|
+
* @param {number} [options.temperature=1] - temperature acts as a knob to adjust the probability that input elements will be selected for the output. At higher values, infrequent words are more likely to be chosen, while at lower values the most frequent inputs are more likely to be output. If no value is provided, then tokens are chosen according to their relative frequency in the input.
|
|
42003
|
+
* @param {boolean} [options.allowDuplicates=false] - if true, allow duplicate sentences in the output
|
|
42004
|
+
* @param {string|string[]} [options.seed] - a seed string or array of tokens to start the generation
|
|
42005
|
+
* @returns {string}
|
|
41998
42006
|
*/
|
|
41999
42007
|
generate(count, options = {}) {
|
|
42008
|
+
let returnsArray = false;
|
|
42009
|
+
if (typeof count === "number") {
|
|
42010
|
+
if (count === 1) {
|
|
42011
|
+
throw Error("For one result, use generate() with no 'count' argument");
|
|
42012
|
+
}
|
|
42013
|
+
returnsArray = true;
|
|
42014
|
+
}
|
|
42000
42015
|
if (arguments.length === 1 && typeof count === "object") {
|
|
42001
42016
|
options = count;
|
|
42002
42017
|
count = 1;
|
|
@@ -42182,7 +42197,7 @@ var _RiMarkov = class _RiMarkov {
|
|
|
42182
42197
|
}
|
|
42183
42198
|
unmarkNodes();
|
|
42184
42199
|
let str = this.untokenize(tokens.map((t) => t.token)).trim();
|
|
42185
|
-
return
|
|
42200
|
+
return returnsArray ? this._splitEnds(str) : str;
|
|
42186
42201
|
}
|
|
42187
42202
|
/**
|
|
42188
42203
|
* Converts the model to a JSON-formatted string for storage or serialization
|
|
@@ -43221,7 +43236,7 @@ markov_default.parent = RiTa;
|
|
|
43221
43236
|
stemmer_default.tokenizer = RiTa.tokenizer;
|
|
43222
43237
|
RiTa.SILENT = false;
|
|
43223
43238
|
RiTa.SILENCE_LTS = false;
|
|
43224
|
-
RiTa.VERSION = "3.0.
|
|
43239
|
+
RiTa.VERSION = "3.0.26";
|
|
43225
43240
|
RiTa.FIRST = 1;
|
|
43226
43241
|
RiTa.SECOND = 2;
|
|
43227
43242
|
RiTa.THIRD = 3;
|