wordLengthRange
Reports the shortest and longest word a language's pools hold, in characters. This is what randWord falls back to when minLengthminLengthmin_length or maxLengthmaxLengthmax_length is left out.
javascript
import { wordLengthRange } from 'randino';
wordLengthRange('ko'); // [1, 4]
wordLengthRange('en'); // [3, 11]
wordLengthRange(); // [1, 21] — every language at oncedart
import 'package:randino/randino.dart';
wordLengthRange(language: WordLanguage.ko); // LengthRange(1, 4)
wordLengthRange(language: WordLanguage.en); // LengthRange(3, 11)
wordLengthRange(); // LengthRange(1, 21) — every language at oncepython
from randino import word_length_range
word_length_range("ko") # (1, 4)
word_length_range("en") # (3, 11)
word_length_range() # (1, 21) — every language at onceArguments
| Argument | Type | Default | Description |
|---|---|---|---|
language | WordLanguageOptionWordLanguage?WordLanguageOption | 'all'null"all" | The language to report on, or every one of them. |
theme | WordThemeOptionWordTheme?WordThemeOption | 'all'null"all" | The theme to report on, or every one of them. |
Both are positional in JavaScript and Python and named in Dart, the way the other language helpers are.
Narrowing the theme narrows the range
A theme is a pool of its own, so its range always sits inside the language's.
javascript
wordLengthRange('en'); // [3, 11]
wordLengthRange('en', 'weather'); // [3, 11]
wordLengthRange('zh'); // [2, 3] — every Chinese noun is two or three charactersdart
wordLengthRange(language: WordLanguage.en); // LengthRange(3, 11)
wordLengthRange(language: WordLanguage.en, theme: WordTheme.weather); // LengthRange(3, 11)
wordLengthRange(language: WordLanguage.zh); // LengthRange(2, 3)python
word_length_range("en") # (3, 11)
word_length_range("en", "weather") # (3, 11)
word_length_range("zh") # (2, 3)Asking for a range the pool cannot satisfy is not an error: the generator answers with the closest word it holds rather than truncating one.
See also
randWord— where the range is used.nicknameLengthRange— the same question for a whole nickname.