Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Generate plausible titles from a list of example titles.
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
titles
.editorconfig
.gitignore
Gruntfile.coffee
LICENSE
README.md
bower.json
component.json
package.json
test.coffee
titlegen.coffee
titlegen.js

README.md

titlegen

Generate plausible titles from a list of example titles by employing a stupid-simple Markov-Chain approach.

titlegen.feed([
  'You Only Live Twice',
  'From Russia with Love',
  'The Man with the Golden Gun',
  'Live and Let Die',
  'Die Another Day'
]);

console.log(titlegen()); // -> "From Russia with the Golden Gun"
console.log(titlegen()); // -> "You Only Live and Let Die Another Day"
console.log(titlegen()); // -> "The Man with Love"

This was originally made for generating video game titles (which is why /titles includes many lists of game titles from multiple platforms), but as the example above shows, it can also be used to generate other types of titles.

Installing

node.js

npm install titlegen

bower

bower install titlegen

<script src="/bower_components/titlegen/titlegen.js" type="text/javascript"></script>

component

component install namuol/titlegen

<script src="/components/namuol-titlegen/titlegen.js" type="text/javascript"></script>

API

titlegen.feed(['Some Title', 'Some Other Title', ...])

Reset the internal Markov-chain and feed it a list of example titles (array of strings).

titlegen()

Generate a new random title and return it as a string.

titlegen.config.min_word_count

Integer; default is 2.

The minimum number of words a generated title can have.

titlegen.config.max_word_count

Integer; default is 16.

The maximum number of words a generated title can have.

titlegen.config.max_attempts

Integer; default is 20.

The maximum number of attempts titlegen will make to generate a title; titles that are too short, too long, or are duplicates of titles from the sample data are discarded.

titlegen.config.splitter

RegExp|String; default is /(\s|'s|[:!?]\s)/

The argument passed to title.split() to divide a title up into "words".

titlegen.config.transform

Function; default removes spaces in front of all instances of :, !, ?, and 's.

A function that alters the title after its words have been joined with spaces.

Building

npm install -g grunt-cli
npm install
grunt # titlegen.coffee -> titlegen.js

Included Data

A bunch of video game title lists are included in ./titles/games. These were acquired from Wikipedia.

If you'd like to add other title list examples (i.e. movies by genre, etc) add a pull request!

Licenses

Code: MIT

Included Title Data: WP:CC-BY-SA

Something went wrong with that request. Please try again.