JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 58
  • Score
    100M100P100Q67479F
  • License MIT

Scrabble's SOWPODS dictionary

Package Exports

  • pf-sowpods
  • pf-sowpods/src/dictionary
  • pf-sowpods/src/sowpods

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (pf-sowpods) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

pf-sowpods

Scrabble's SOWPODS dictionary - The SOWPODS dictionary with related functionality.

Examples

// Require the module
var sowpods = require('pf-sowpods');

sowpods[62];    // -> 'ABAPICAL'
sowpods.length; // -> 267751

// A trie structure is included, too
sowpods.trie.H.A.P.H.T.A.R.A._; // -> true

// Verify words
sowpods.verify('banana'); // -> true
sowpods.verify('foobar'); // -> false

// Define words / get related word forms
sowpods.define('moo', function(err, data) {
  console.log(data);
});
// {
//   word: 'MOO',
//   definition: 'to make the deep, moaning sound of a cow',
//   related: [ 'MOOED', 'MOOING', 'MOOS' ]
// }

// Find anagrams out of letters
sowpods.anagram('EYBTOR*');
// -> [ 'BOOTERY', 'BARYTE', ..., 'YU', 'ZO' ]

API

sowpods

({Array}): An alphabetized array of the SOWPODS dictionary. All letters are capitalized.

var _ = require('lodash');
_.filter(sowpods, {length: 5});
// -> [ 'AAHED', 'AALII', ..., 'ZYMES', 'ZYMIC' ]

sowpods.trie

({Object}): A trie structure of the words where the nodes are single capitalized characters. The node ._ === true indicates an End-of-word. Lodash's get() function may be useful here.

var _ = require('lodash');
_.get(sowpods.trie, 'A.B.C.D', {});
// -> {}
_.get(sowpods.trie, 'DERMI'.split());
// -> {
//   C: { _: true },
//   S: { _: true,
//     E: { S: { _: true } }
//   }
// }

sowpods.verify(word)

Arguments

  1. word (String): A word to check (case-insensitive).

Returns

  • (Boolean): true if the word is in SOWPODS, false otherwise.

This function crawls the trie to determine if the word exists.

sowpods.verify('banana'); // -> true
sowpods.verify('foobar'); // -> false

sowpods.anagram(str)

Arguments

  1. str (String): The letters to anagram (case-insensitive).

Returns

  • (Array): All possible single word anagrams.

Characters in str which are not alphabetic, are considered to be wildcards. This function crawls the trie as long as the next node is available in the letters provided.

sowpods.anagram('EYBTOR*');
// -> [ 'BOOTERY', 'BARYTE', ..., 'YU', 'ZO' ]

sowpods.random([count])

Arguments

  1. [count] (number): The number of random words to return.

Returns

  • (String|Array): Some random words.

If count is undefined, it returns a single string. Otherwise it returns an array of length count of random strings.

sowpods.random();  // -> 'PICANINNIES'
sowpods.random(2); // -> [ 'REFRESHENS', 'EPILOGUIZING' ]

sowpods.define(search, callback)

Arguments

  1. search (String): The word to lookup.
  2. callback (Function): Callback function with signature (err, data).

data is an Object with keys word, definition, and related.

sowpods.define('moo', function(err, data) {
  console.log(data);
});
// {
//   word: 'MOO',
//   definition: 'to make the deep, moaning sound of a cow',
//   related: [ 'MOOED', 'MOOING', 'MOOS' ]
// }