sentenceLengthRange
Every sentence length the language can produce, in characters. That is what randSentence falls back to when minLength or maxLength is omitted.
import { sentenceLengthRange } from 'randino';
sentenceLengthRange('ko'); // [5, 55]
sentenceLengthRange('en'); // [11, 118]
sentenceLengthRange('zh'); // [4, 33]
sentenceLengthRange(); // [4, 147] — every language at onceimport 'package:randino/randino.dart';
sentenceLengthRange(WordLanguage.ko); // LengthRange(5, 55)
sentenceLengthRange(WordLanguage.en); // LengthRange(11, 118)
sentenceLengthRange(WordLanguage.zh); // LengthRange(4, 33)
sentenceLengthRange(); // LengthRange(4, 147) — every language at oncefrom randino import sentence_length_range
sentence_length_range("ko") # (5, 55)
sentence_length_range("en") # (11, 118)
sentence_length_range("zh") # (4, 33)
sentence_length_range() # (4, 147) — every language at once| Parameter | Type | Default | Description |
|---|---|---|---|
language | WordLanguageOptionWordLanguage?WordLanguageOption | 'all'null"all" | The language to measure, or every one at once. |
Returns [min, max]a LengthRange(min, max), both inclusive.
The default range
The range is wide because its ends are extremes. The lower end is the shortest shape with the shortest words in it, and the upper end the longest shape with a modifier on every phrase. A sentence that lands anywhere between the two is a sentence the language can write, and the frame weights rather than the ends decide which one you get.
That is also what makes narrowing it useful. Ask for a short range and the shapes that cannot fit drop out:
randSentence({ language: 'en', minLength: 14, maxLength: 26, count: 3 });
// ['The brave wine gathers.', 'The oni lifts the icy tea.', 'The toe aches in the lake.']randSentence(language: WordLanguage.en, minLength: 14, maxLength: 26, count: 3);
// [The brave wine gathers., The oni lifts the icy tea., The toe aches in the lake.]rand_sentence(language="en", min_length=14, max_length=26, count=3)
# ['The brave wine gathers.', 'The oni lifts the icy tea.', 'The toe aches in the lake.']Length picks the shape, not the words: a range too narrow for a modifier drops the modifier rather than truncating anything. A range no shape of the language can satisfy is answered with the closest one it has.
See also
randSentence— the generator these bounds belong to.- Constants — the ceiling both bounds are clamped to.