Skip to content

sentenceLengthRange

Every sentence length the language can produce, in characters. That is what randSentence falls back to when minLength or maxLength is omitted.

javascript
import { sentenceLengthRange } from 'randino';

sentenceLengthRange('ko'); // [5, 55]
sentenceLengthRange('en'); // [11, 118]
sentenceLengthRange('zh'); // [4, 33]
sentenceLengthRange(); // [4, 147] — every language at once
dart
import '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 once
python
from 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
ParameterTypeDefaultDescription
languageWordLanguageOptionWordLanguage?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:

javascript
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.']
dart
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.]
python
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.

Released under the MIT License