Skip to main content
Home

Markov chain based name generator in TypeScript

This package works with Node.jsIt is unknown whether this package works with Cloudflare Workers, Deno, Bun, Browsers
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 Bun
It is unknown whether this package works with Browsers
JSR Score
94%
Published
a year 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.

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@kari/markov-namegen

Import symbol

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

Import directly with a jsr specifier

import * as markov_namegen from "jsr:@kari/markov-namegen";

Add Package

pnpm i jsr:@kari/markov-namegen
or (using pnpm 10.8 or older)
pnpm dlx jsr add @kari/markov-namegen

Import symbol

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

Add Package

yarn add jsr:@kari/markov-namegen
or (using Yarn 4.8 or older)
yarn dlx jsr add @kari/markov-namegen

Import symbol

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

Add Package

npx jsr add @kari/markov-namegen

Import symbol

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

Add Package

bunx jsr add @kari/markov-namegen

Import symbol

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