-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.d.ts
66 lines (60 loc) · 1.91 KB
/
types.d.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
declare module "mrkv" {
declare interface GenerateOptions {
/**
* Sentence to start off generating from. Only the last word is counted, but the rest of the input
* is still prepended to the output.
*/
start?: string;
/**
* Maximum length for the output string. Defaults to 40 characters.
*
* The output _may_ exceed this maximum length in rare cases but the library will stop
* generation after the string reaches the length defined in this option.
*
* @default 40
*/
length?: number;
}
/**
* Data loaded from a sentence array based on the probability of meeting the next string.
*/
export type Corpus = Map<string | symbol, (string | symbol)[]>;
/**
* Generate a similar sentence from a list of sentences, which will be consumed to generate a
* markov chain.
*
* @param [options] Options to influence how data is generated.
*/
export async function generateFromArray(
array: string[],
options?: GenerateOptions
): Promise<string>;
/**
* Generate a sentence based on the {@link Corpus} provided.
*
* @param [options] Options to influence how data is generated.
*/
export function generateFromMap(
map: Corpus,
options?: GenerateOptions
): string;
/**
* Take an array of sentences and return a {@link Corpus}
* representing the consumed sentences' patterns.
*/
export default async function loadArray(sentences: string[]): Promise<Corpus>;
/**
* Identical to {@link loadArray} in operation, loads a newline-delimited
* list of sentences from a file.
*
* @param name File to read from.
*/
function loadFile(name: string): Promise<Corpus>;
/**
* Generate a sentence from a file of newline-delimited sentences. Identical
* in operation to {@link generateFromMap}.
*
* @param name File to read from.
*/
function generateFile(name: string, options?: {}): Promise<string>;
}