Skip to content

Latest commit

 

History

History
78 lines (56 loc) · 1.9 KB

File metadata and controls

78 lines (56 loc) · 1.9 KB

BytecodeApi.LanguageGenerator

Library for arbitrary generation of words, sentences, names, and other language elements.

Examples

BytecodeApi.LanguageGenerator

WordGenerator

Generate a random word. The number of characters and the chance of two consecutive consonants or vocals can be specified in the constructor of WordGenerator.

WordGenerator wordGenerator = new()
{
	MinLength = 3,
	MaxLength = 10,
	DoubleConsonantChance = .1,
	DoubleVovelChance = .1
};

string randomWord = wordGenerator.Generate();
SentenceGenerator

Generate a random sentence. A WordGenerator is passed to this instance that generates each word. Additional settings, like how many commas are inserted, can be configured in the constructor of SentenceGenerator.

WordGenerator wordGenerator = ...;

SentenceGenerator sentenceGenerator = new()
{
	WordGenerator = wordGenerator,
	MinWords = 3,
	MaxWords = 10,
	CommaChance = .2,
	FinishPunctuation = new[] { '.', '.', '.', '?', '!' }
};

string randomSentence = sentenceGenerator.Generate();
TextGenerator

Generate random text with multiple sentences. A SentenceGenerator is passed to this instance that generates each sentence. Additional settings, like how many sentences are used, can be configured in the constructor of TextGenerator.

SentenceGenerator sentenceGenerator = ...;

TextGenerator textGenerator = new()
{
	SentenceGenerator = sentenceGenerator,
	MinSentenceCount = 10,
	MinSentenceCount = 20,
	LineBreakChance = 0,
	ParagraphChance = .1
};

string randomText = textGenerator.Generate();

See also

  • NameGenerator to generate first/last names
  • LoremIpsumGenerator to generate text placeholders with lorem ipsum paragraphs.

Changelog

3.0.0 (08.09.2023)

  • Initial release