0% found this document useful (0 votes)
30 views2 pages

Deletar 4

The document outlines the functions of a random text generator, specifically focusing on methods to teach the generator new words, including learnRight, learnLeft, and learnBoth. Each method allows for customization through parameters such as origin, multiplier, and isRaw. Examples are provided to demonstrate how to use these functions to generate names based on learned inputs.

Uploaded by

scriiiiiiibd
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views2 pages

Deletar 4

The document outlines the functions of a random text generator, specifically focusing on methods to teach the generator new words, including learnRight, learnLeft, and learnBoth. Each method allows for customization through parameters such as origin, multiplier, and isRaw. Examples are provided to demonstrate how to use these functions to generate names based on learned inputs.

Uploaded by

scriiiiiiibd
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

Functions

learn
An alias for learnRight.

learnRight
Teaches the generator a new word (left -> right).

Syntax
randomTextGenerator.learn(example, origin, multiplier, isRaw);
// or
randomTextGenerator.learnRight(example, origin, multiplier, isRaw);
example - string or array of strings
origin - optional, string, by default "_default"
Specifies the origin of a word.
multiplier - optional, number, by default 1
The importance of this example.
isRaw - optional, boolean, by default false
If true the input is not treated like a word, but rather like a part of a word.

Returns nothing.

Example
randomTextGenerator.learnRight("Mark");
randomTextGenerator.learnRight("Henry");
randomTextGenerator.learnRight("Bob");
randomTextGenerator.learnRight("John");
randomTextGenerator.learn("David"); // learn is an alias for learnRight.
randomTextGenerator.learn("James");

for (let i=0; i<8; ++i) {


let name=randomTextGenerator.generate();
console.log(name);
}
// Jamen
// Mary
// Jark
// Job
// Bohn
// Dark
// John
// Jamen

// You can also provide starting letters


for (let i=0; i<4; ++i) {
let name=randomTextGenerator.generate("J");
console.log(name);
}
// Job
// Jary
// Javid
// James
learnLeft
Teaches the generator a new word (right -> left).

Syntax
randomTextGenerator.learnLeft(example, origin, multiplier, isRaw);
example - string or array of strings
origin - optional, string, by default "_default"
Specifies the origin of a word.
multiplier - optional, number, by default 1
The importance of this example.
isRaw - optional, boolean, by default false
If true the input is not treated like a word, but rather like a part of a word.

Returns nothing.

Example
randomTextGenerator.learnLeft("Mark");
randomTextGenerator.learnLeft("Henry");
randomTextGenerator.learnLeft("Bob");
randomTextGenerator.learnLeft("John");
randomTextGenerator.learnLeft("David");
randomTextGenerator.learnLeft("James");

for (let i=0; i<4; ++i) {


let name=randomTextGenerator.generateLeft();
console.log(name);
}
// David
// Henry
// Jark
// Bob

// All the names are going to end with "k"


for (let i=0; i<4; ++i) {
let name=randomTextGenerator.generateLeft("k");
console.log(name);
}
// Dark
// Bohnrk
// Henrk
// Jark

for (let i=0; i<4; ++i) {


let name=randomTextGenerator.generateLeft("y");
console.log(name);
}
// Johnry
// Bohnry
// Jary
// Dary
learnBoth
Calls both learnRight and learnLeft.

Syntax
randomTextGenerator.learnBoth(example, origin, multiplier, isRaw);
example - string or array of strings
origin - optional, string, by default "_default"
Specifies the origin of a word.
multiplier - optional, number, by default 1
The importance of this example.
isRaw - optional, boolean, by default false
If true the input is not treated like a word, but rather like a part of a word.

You might also like