Deletar 3

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 3

Obtaining

Note: The include syntax is temporary in order to provide legacy support. In the
upcoming update it is going to change.

HTML
<script src="https://raw.githubusercontent.com/Rafal-Majewski/random-text-
generator-js/master/random_text_generator_browser.js"></script>
node.js
npm install random-text-generator
const RandomTextGenerator=require("random-text-generator");
Getting Started
All the values shown in settings are the default values.

// You can change the settings on the fly as well, just write
randomTextGenerator.settingName=newValue.
let settings={
tries: 80, // That many times the generator will try to generate. If exceeded
the generator returns null.
safeMode: true, // Safe mode makes the generation process faster, but makes
the output a bit worse.
forceCombiningOrigins: false, // Force the generator to combine origins. See
examples for details on origins.
minLength: 1, // Minimal length (inclusive) of output.
maxLength: 400, // Maximal length (inclusive) of output.
deepness: 40, // That many previous characters are used while determining a
new character. The greater the generator is more intelligent, but needs more
memory.
trust: 2, // That many times a substring of characters must occur in order to
be used while generating.
weightsLeft: {} // Startings weights for generating right -> left.
weightsRight: {} // Startings weights for generating left -> right.
splitter: "", // A character that is use to split characters. Basically use
"" while generating words and " " while generating sentences.
startingCharacter: String.fromCharCode(2), // A character that every word
starts with. You don't include that in your input examples and it's not included in
the generated output.
endingCharacter: String.fromCharCode(3), // A character that every word ends
with. You don't include that word in your input examples and it's not included in
the generated output.
};
// Initialize an instance of the generator with custom settings
let randomTextGenerator=new RandomTextGenerator(settings);
// Or initialize it with the default settings
let randomTextGenerator=new RandomTextGenerator();
Examples
Usernames
const RandomTextGenerator=require("random-text-generator");

// Create an instance of the generator with default settings.


let randomTextGenerator=new RandomTextGenerator();

// Make an array with some usernames.


let usernames=["StinkyPoop", "Alextron234", "BattleDash", "berkey10", "Ezblox23",
"robiko858", "zakizakowski", "MrArtur1337", "AzisDeus", "AustrianPainter1889",
"pomidorek2pl", "JoeMamma", "MafiaBoss75", "SciManDan", "siuras_ogoras986",
"jacob.flix", "malario", "BenDrowned", "pickupthefox", "okboomer", "GHPL",
"Firstbober"];

// Pass every username to the generator.


for (let username of usernames) randomTextGenerator.learn(username);

// console.log twelve new nicknames.


for (let i=0; i<12; ++i) {
let username=randomTextGenerator.generate();
console.log(username);
}
// AleDras9
// JoreMamaliky1886
// ziriaBateDeDas_ownkiziMrsDer
// Mrey10
// Ezidoomiskblex
// oeMan
// jan
// Fioomer
// Alox
// GHPaBober
// zakizbi
// Ezakizako889
Multiple Origins Generation
const RandomTextGenerator=require("random-text-generator");

// Create an instance of the generator with default settings.


let randomTextGenerator=new RandomTextGenerator();

let americanCities=["New York","Los


Angeles","Chicago","Houston","Phoenix","Philadelphia","San Antonio","San
Diego","Dallas","San Jose","Austin","Jacksonville","Fort Worth","Columbus","San
Francisco","Charlotte","Indianapolis","Seattle","Denver","Washington","Boston","El
Paso","Detroit","Nashville","Portland","Memphis","Oklahoma City","Las
Vegas","Louisville","Baltimore","Milwaukee","Albuquerque","Tucson","Fresno","Mesa",
"Sacramento","Atlanta","Kansas City","Colorado
Springs","Miami","Raleigh","Omaha","Long Beach","Virginia
Beach","Oakland","Minneapolis","Tulsa","Arlington","Tampa","New
Orleans","Wichita","Cleveland","Bakersfield","Aurora","Anaheim","Honolulu","Santa
Ana","Riverside","Corpus Christi","Lexington","Stockton","Henderson","Saint
Paul","St.
Louis","Cincinnati","Pittsburgh","Greensboro","Anchorage","Plano","Lincoln","Orland
o","Irvine","Newark","Toledo","Durham","Chula Vista","Fort Wayne","Jersey
City","St.
Petersburg","Laredo","Madison","Chandler","Buffalo","Lubbock","Scottsdale","Reno","
Glendale","Gilbert","Winston–Salem","North Las
Vegas","Norfolk","Chesapeake","Garland","Irving","Hialeah","Fremont","Boise","Richm
ond","Baton Rouge","Spokane","Des Moines","Tacoma","San
Bernardino","Modesto","Fontana","Santa
Clarita","Birmingham","Oxnard","Fayetteville","Moreno
Valley","Rochester","Glendale","Huntington Beach","Salt Lake City","Grand
Rapids","Amarillo","Yonkers","Aurora","Montgomery","Akron","Little
Rock","Huntsville","Augusta","Port St. Lucie","Grand
Prairie","Columbus","Tallahassee","Overland Park","Tempe","McKinney","Mobile","Cape
Coral","Shreveport","Frisco","Knoxville","Worcester","Brownsville","Vancouver","For
t Lauderdale","Sioux Falls","Ontario","Chattanooga","Providence","Newport
News","Rancho Cucamonga","Santa Rosa","Oceanside","Salem","Elk Grove","Garden
Grove","Pembroke Pines","Peoria","Eugene","Corona","Cary","Springfield","Fort
Collins","Jackson","Alexandria","Hayward","Lancaster","Lakewood","Clarksville","Pal
mdale","Salinas","Springfield","Hollywood","Pasadena","Sunnyvale","Macon","Kansas
City","Pomona","Escondido","Killeen","Naperville","Joliet","Bellevue","Rockford","S
avannah","Paterson","Torrance","Bridgeport","McAllen","Mesquite","Syracuse","Midlan
d","Pasadena","Murfreesboro","Miramar","Dayton","Fullerton","Olathe","Orange","Thor
nton","Roseville","Denton","Waco","Surprise","Carrollton","West Valley
City","Charleston","Warren","Hampton","Gainesville","Visalia","Coral
Springs","Columbia","Cedar Rapids","Sterling Heights","New
Haven","Stamford","Concord","Kent","Santa Clara","Elizabeth","Round Rock","Thousand
Oaks","Lafayette","Athens","Topeka","Simi
Valley","Fargo","Norman","Columbia","Abilene","Wilmington","Hartford","Victorville"
,"Pearland","Vallejo","Ann
Arbor","Berkeley","Allentown","Richardson","Odessa","Arvada","Cambridge","Sugar
Land","Beaumont","Lansing","Evansville","Rochester","Independence","Fairfield","Pro
vo","Clearwater","College Station","West Jordan","Carlsbad","El
Monte","Murrieta","Temecula","Springfield","Palm Bay","Costa
Mesa","Westminster","North Charleston","Miami Gardens","Manchester","High
Point","Downey","Clovis","Pompano Beach","Pueblo","Elgin","Lowell","Antioch","West
Palm
Beach","Peoria","Everett","Ventura","Centennial","Lakeland","Gresham","Richmond","B
illings","Inglewood","Broken Arrow","Sandy Springs","Jurupa
Valley","Hillsboro","Waterbury","Santa Maria","Boulder","Greeley","Daly
City","Meridian","Lewisville","Davie","West Covina","League
City","Tyler","Norwalk","San Mateo","Green Bay","Wichita
Falls","Sparks","Lakewood","Burbank","Rialto","Allen","El Cajon","Las
Cruces","Renton","Davenport","South
Bend","Vista","Tuscaloosa","Clinton","Edison","Woodbridge","San
Angelo","Kenosha","Vacaville"];

let
polishCities=["Warszawa","Kraków","Łódź","Wrocław","Poznań","Gdańsk","Szczecin","By
dgoszcz","Lublin","Białystok","Katowice","Gdynia","Częstochowa","Radom","Toruń","So
snowiec","Kielce,Rzeszów","Gliwice","Zabrze","Olsztyn","Bielsko-
Biała","Bytom","Zielona Góra","Rybnik","Ruda Śląska","Opole","Tychy","Gorzów
Wielkopolski","Płock","Dąbrowa
Górnicza","Elbląg","Wałbrzych","Włocławek","Tarnów","Chorzów","Koszalin","Kalisz"]

// Teach the generator the names of the cities, but preserve its origin.
for (let americanCity of americanCities) randomTextGenerator.learn(americanCity,
"americanCity");
for (let polishCity of polishCities) randomTextGenerator.learn(polishCity,
"polishCity");

// console.log twelve new city names.


for (let i=0; i<12; ++i) {
// randomTextGenerator.generate(text, origins, isRaw);
// we are going to leave the "text" field null, because we don't want any
specific characters at the beginning.
// origins is an array where you can specify the origins you want the
generator to generate from, in this case you can leave it as null, because by
default the generator uses all origins
let city=randomTextGenerator.generate(null, ["polishCity", "americanCity"]);

You might also like