randWord
Generates everyday words and returns count of them as strings. Animals, things, nature and ideas, across twenty-nine themes in nine languages, and never a person name. With output: 'detail' it reports the language and theme behind each word.
These are the pools randNickname is built from, handed back with nothing added to them.
import { randWord } from 'randino';
randWord();
// ['Lantern']import 'package:randino/randino.dart';
randWord();
// [Lantern]from randino import rand_word
rand_word()
# ['Lantern']Options
Every option is optional, and the defaults are what the empty call above uses.
| Option | Type | Default | Description |
|---|---|---|---|
language | WordLanguageOptionWordLanguage?WordLanguageOption | 'all'null"all" | Language of the generated words. Left out, it picks one per word and mixes them all. |
theme | WordThemeOptionWordTheme?WordThemeOption | 'all'null"all" | What the words are about. Each theme also has a function of its own. |
count | numberintint | 1 | How many words to return. Clamped to 0 … 10000. |
realism | RandRealismRandRealismRandRealism | 'real'RandRealism.real"real" | real draws from the pools, invented builds words that only read like the language, and mixed decides per word. |
vocabulary | RandVocabularyRandVocabularyRandVocabulary | 'full'RandVocabulary.full"full" | basic draws the everyday words, common those and the ones an adult uses now and then, full every word the pools hold. |
minLengthminLengthmin_length | numberint?int | None | pools | Minimum length in characters. Left out, it follows what the pools hold. |
maxLengthmaxLengthmax_length | numberint?int | None | pools | Maximum length in characters. A range the pool cannot serve is answered with the closest word. |
startsWithstartsWithstarts_with | stringString?str | —null"" | Keep only words whose first character is this one. |
unique | booleanboolbool | falsefalseFalse | Never return the same word twice. Returns fewer than asked once a pool runs out. |
random | () => numberRandom?Callable[[], float] | None | —nullNone | Where the randomness comes from. Defaults to the platform's ordinary generator. |
output | RandOutputRandOutput | 'value'"value" | Strings, or one WordDetail per word. |
The same table is on each of the twenty-nine pages below, drawn from one component rather than written out thirty times. Everything but language and theme is an option every generator in the package takes, and means the same thing on each of them.
Dart has no output; the detail output is randWordDetails there.
One function per theme
A theme is an option and a function both. Each of the twenty-nine is randWord with the theme already chosen, and each has a page of its own. The words each theme holds are on Themes.
randAnimal · randObject · randNature · randPlant · randGem · randConcept · randMyth · randJob · randMusic · randPlace · randFood · randSport · randVehicle · randProduct · randColor · randFinance · randTech · randWeather · randSpace · randTime · randEmotion · randBody · randClothing · randTool · randDrink
import { randAnimal, randFood, randGem } from 'randino';
randAnimal({ language: 'en', count: 3 }); // ['Otter', 'Falcon', 'Lynx']
randFood({ language: 'en', count: 2 }); // ['Dumpling', 'Cocoa']
randGem({ language: 'en', count: 2, unique: true }); // ['Obsidian', 'Bronze']import 'package:randino/randino.dart';
randAnimal(language: WordLanguage.en, count: 3); // [Otter, Falcon, Lynx]
randFood(language: WordLanguage.en, count: 2); // [Dumpling, Cocoa]
randGem(language: WordLanguage.en, count: 2, unique: true); // [Obsidian, Bronze]The themed functions return List<String> only. For the detail form, pass the theme to randWordDetails. Dart has no overloads, and a detail twin for each of the twenty-nine themes would be twenty-nine functions too many.
from randino import rand_animal, rand_food, rand_gem
rand_animal(language="en", count=3) # ['Otter', 'Falcon', 'Lynx']
rand_food(language="en", count=2) # ['Dumpling', 'Cocoa']
rand_gem(language="en", count=2, unique=True) # ['Obsidian', 'Bronze']They take every option randWord does except theme, which they answer.
Length
Left out, minLengthminLengthmin_length and maxLengthmaxLengthmax_length fall back to what the pools actually hold, which is what wordLengthRange reports. A range the pool cannot satisfy is answered with the closest word it has rather than a truncated one.
randWord({ language: 'en', theme: 'animal', maxLength: 4, count: 4 });
// ['Cat', 'Ant', 'Frog', 'Carp']
randWord({ language: 'en', minLength: 9, count: 3 });
// ['Saxophone', 'Spaghetti', 'Spaceship']randWord(language: WordLanguage.en, theme: WordTheme.animal, maxLength: 4, count: 4);
// [Cat, Ant, Frog, Carp]
randWord(language: WordLanguage.en, minLength: 9, count: 3);
// [Saxophone, Spaghetti, Spaceship]rand_word(language="en", theme="animal", max_length=4, count=4)
# ['Cat', 'Ant', 'Frog', 'Carp']
rand_word(language="en", min_length=9, count=3)
# ['Saxophone', 'Spaghetti', 'Spaceship']Invented words
realism has three levels: real draws from the pools, invented builds words that only read like the language, and mixed decides per word.
randWord({ language: 'en', realism: 'invented', count: 4 });
// ['Sterath', 'Lisleen', 'Kaezan', 'Mibaeth']
randWord({ language: 'en', realism: 'mixed', count: 4 });
// ['Blorin', 'Meadow', 'Tavren', 'Compass']randWord(language: WordLanguage.en, realism: RandRealism.invented, count: 4);
// [Sterath, Lisleen, Kaezan, Mibaeth]rand_word(language="en", realism="invented", count=4)
# ['Sterath', 'Lisleen', 'Kaezan', 'Mibaeth']An invented word can spell a real one by accident, since the syllable templates do come out as Snake now and then. The theme is then reported rather than hidden.
Common words
The pools hold apple and thallium, doctor and cooper, 사과 and 탈륨, and a draw over all of them comes back with a specialist's word about as often as an everyday one. vocabulary says how common the words have to be. basic is the everyday words, which nearly every speaker uses and a child already knows; common is those and the words an adult knows and uses now and then; full is every word the pools hold, and the default. Each level holds the ones below it, so common is the pools with the rare words left out rather than a band of middling ones.
randWord({ language: 'ko', vocabulary: 'basic', count: 5 });
// ['사과', '고양이', '의사', '컴퓨터', '가위']
randWord({ language: 'en', theme: 'gem', vocabulary: 'basic', count: 4 });
// ['Gold', 'Diamond', 'Pearl', 'Silver']randWord(language: WordLanguage.ko, vocabulary: RandVocabulary.basic, count: 5);
// [사과, 고양이, 의사, 컴퓨터, 가위]rand_word(language="ko", vocabulary="basic", count=5)
# ['사과', '고양이', '의사', '컴퓨터', '가위']The levels are a judgement made per language about that language's own words — 탈륨 is rare because nobody says it, not because thallium is obscure — and every theme keeps a handful of basic words, so randGem({ vocabulary: 'basic' }) still answers. randNickname takes the same option for the noun it is built around, and randSentence for every noun of the sentence — where the default is common rather than full, because a sentence is read; a word the caller required, an invented word and a person's name are not the pools', and have no level.
The detail output
randWord({ language: 'en', theme: 'plant', output: 'detail' });
// [{ word: 'Cedar', language: 'en', theme: 'plant' }]randWordDetails(language: WordLanguage.en, theme: WordTheme.plant).first;
// WordDetail(Cedar, en, plant)Dart has neither overloads nor union types, so the detail form is its own function.
rand_word(language="en", theme="plant", output="detail")
# [WordDetail(word='Cedar', language='en', theme='plant')]theme is null for an invented word that matches nothing in the pools.
See also
- Themes — the twenty-nine of them, and the function each one has.
wordLengthRange— what a language's pools can produce.randNickname— the same words, put together.randModifier— a modifier in front of a word you already have.