LexiconLang.Language 1.5.0

dotnet add package LexiconLang.Language --version 1.5.0
                    
NuGet\Install-Package LexiconLang.Language -Version 1.5.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="LexiconLang.Language" Version="1.5.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LexiconLang.Language" Version="1.5.0" />
                    
Directory.Packages.props
<PackageReference Include="LexiconLang.Language" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add LexiconLang.Language --version 1.5.0
                    
#r "nuget: LexiconLang.Language, 1.5.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package LexiconLang.Language@1.5.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=LexiconLang.Language&version=1.5.0
                    
Install as a Cake Addin
#tool nuget:?package=LexiconLang.Language&version=1.5.0
                    
Install as a Cake Tool

LexiconLang.Net

A complete C#/.NET port of the deterministic procedural generation system LexiconLang. Designed for games, tabletop tools, and narratives, focusing on absolute determinism, composability, and 1-to-1 parity with the TypeScript library.

Features

  • Absolute Determinism: The entire generation tree is driven by a hierarchical Context seeded randomly or strictly. Context.Child("node") automatically forks the Random Number Generator to maintain isolated state streams—meaning adding or removing content elsewhere won't shift unrelated lists!
  • Data-Driven & Composable: Use small atomic string/object generators combined via Combinators.Repeat, Compose, WeightedList, etc.
  • Tracery-style Grammars: LexiconLang.Grammar supports complex, recursively expanded templates and custom text modifiers (#name.capitalize#).
  • Markov Models: LexiconLang.Markov allows you to train text models to procedurally generate cohesive names and prose.
  • Phonotactics & Glyphs: LexiconLang.Language and LexiconLang.Glyphs enable generation of culturally distinct languages, unique words, and corresponding SVG procedural runes/glyphs.
  • Content Packs out-of-the-box: LexiconLang.Fantasy, LexiconLang.SciFi, and LexiconLang.Modern.

Included Packages

  • LexiconLang.Core (RNG, Context, Combinators)
  • LexiconLang.Grammar
  • LexiconLang.Markov
  • LexiconLang.Language
  • LexiconLang.Glyphs
  • LexiconLang.Fantasy, LexiconLang.SciFi, LexiconLang.Modern

Usage Examples

1. Minimal Quickstart

using System;
using LexiconLang.Core;
using LexiconLang.Fantasy;

class Program
{
    static void Main()
    {
        // 1. Initialize root context with a deterministic seed
        var ctx = LexiconContext.Create("hello-world");

        // 2. Generate random results from an included content pack
        var faction = FantasyEncounters.FactionGenerator.Generate(ctx.Child("faction"));
        var title = FantasyEncounters.TitleGenerator.Generate(ctx.Child("title"));

        Console.WriteLine($"The {title} of {faction}");
    }
}

2. Custom Generators

public record IronKnight(string Name, string Rank);

var house = Combinators.OneOf<string, object?>("Vael", "Kessel", "Vorden", "Bayard");

var rank = Combinators.WeightedList<string, object?>(new[]
{
    new Weighted<string>("Squire", 4),
    new Weighted<string>("Knight", 8),
    new Weighted<string>("Knight-Captain", 2),
});

var ironKnight = Combinators.Compose<IronKnight, object?>("ironknight", ctx =>
{
    return new IronKnight(
        "Sir " + house.Generate(ctx.Child("name")),
        rank.Generate(ctx.Child("rank"))
    );
});

var rootCtx = LexiconContext.Create("iron-watch");
var k = ironKnight.Generate(rootCtx.Child("watch:0"));

3. Grammars (Tracery Style)

var rules = new GrammarRules<object?>
{
    { "start", new Weighted<string>[]
        {
            new ("#prefix.capitalize# #element.capitalize# #form.capitalize#", 5),
            new ("the #adj.capitalize# #form.capitalize#", 2)
        }
    },
    { "prefix", new[] { "lesser", "greater", "true" } },
    { "element", new[] { "fire", "frost", "shadow" } },
    { "form", new[] { "bolt", "ward", "veil" } },
    { "adj", new[] { "unsleeping", "patient", "errant" } }
};

var spellName = new Grammar<object?>(rules);
var ctx = LexiconContext.Create("spellbook");

// Prints e.g. "Greater Shadow Bolt"
Console.WriteLine(spellName.Generate(ctx)); 

4. Markov Model

var corpus = new[] { "caernarfon", "carmarthen", "ceredigion", "conwy", "gwynedd" };
var entries = corpus.Select(x => new TrainEntry(x));

// Train the generator
var model = Trainer.Train(entries, new TrainOptions(Order: 3, MinLength: 5, MaxLength: 12));
var townName = Sampler.AsGenerator<object?>(model);

var ctx = LexiconContext.Create("welsh-towns");
Console.WriteLine(townName.Generate(ctx));

5. Culture & Glyphs

var ctx = LexiconContext.Create("glyph-demo");

// Generate a culturally appropriate name and translation
var dwarfName = Templates.GenerateName(FantasyCultures.Dwarvish, "given", ctx.Child("dwarf"));

// Setup the glyph system to be phoneme-based
var visualSystem = new VisualGlyphSystem(
    Name: "dwarvish-runes",
    Strategy: MappingStrategy.Phoneme,
    Complexity: Complexity.Medium,
    Format: RenderFormat.Svg,
    Palette: new[] { "#333", "#666" }
);

// Map the generated name strictly structure-to-glyph
var dwarfGlyphs = GlyphGenerator.GlyphsFor(dwarfName, visualSystem, ctx.Child("dwarf"));

Build and test

dotnet build -warnaserror
dotnet test LexiconLang.Net.slnx
Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on LexiconLang.Language:

Package Downloads
LexiconLang.SciFi

Sci-fi content pack, cultures, and semantic data for LexiconLang .NET.

LexiconLang.Fantasy

Fantasy content pack, cultures, and semantic data for LexiconLang .NET.

LexiconLang.Glyphs

Procedural glyph generation and rendering (SVG/canvas/unicode) for LexiconLang .NET.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.5.0 227 5/19/2026
1.4.1 140 5/19/2026
1.4.0 137 5/19/2026
1.3.0 121 5/19/2026
1.2.0 127 5/19/2026
1.1.0 126 5/19/2026
1.0.0 151 5/19/2026