Skip to main content

Markov chain based name generator in TypeScript

Works with
It is unknown whether this package works with Bun
It is unknown whether this package works with Cloudflare Workers
This package works with Node.js
It is unknown whether this package works with Deno
It is unknown whether this package works with Browsers
JSR Score
94%
Published
3 months ago (1.0.3)

markov-namegen

This is a TypeScript port of markov-namegen-lib. It is a Markov chain based name or word generator library.

Features

Offers most of the features available in the reference Haxe implementation

  • A simplified Katz back-off using high order models - look up to "n" characters back.
  • Sort and filter generated strings by length, start, end, and content.
  • Dirichlet prior parameter.

Usage

const data = ["lots", "of", "words", "to", "learn", "from"];
const namegen = new NameGenerator(data, 3, 0, false);
console.log(namegen.generate(5, 11, "", "", "", ""));

or if you want to generate a lot of names in one go

console.log(namegen.generateNames(20, 5, 11, "", "", "", ""))

For training data and word lists, see the original project's word_lists folder.

Notes

  • The original Haxe implementation can target Javascript, so both of these can ultimately compile/transpile down to that. So if you are just looking for a JavaScript implementation, you might want to use the original instead.

License

Distributed under the MIT License. See LICENSE for more information.

Add Package

deno add @kari/markov-namegen

Import symbol

import * as mod from "@kari/markov-namegen";

Add Package

npx jsr add @kari/markov-namegen

Import symbol

import * as mod from "@kari/markov-namegen";

Add Package

yarn dlx jsr add @kari/markov-namegen

Import symbol

import * as mod from "@kari/markov-namegen";

Add Package

pnpm dlx jsr add @kari/markov-namegen

Import symbol

import * as mod from "@kari/markov-namegen";

Add Package

bunx jsr add @kari/markov-namegen

Import symbol

import * as mod from "@kari/markov-namegen";