forked from jeresig/trie-js
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
0.3.0: removed findAnagramsSafely in favor of findAnagrams with and w…
…ithout options. fixed formatting bug. added readme and formatting example
- Loading branch information
1 parent
2bf81ba
commit 7b52d46
Showing
7 changed files
with
92 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
|
||
# anagram | ||
|
||
A simple anagram generation library for use with nodejs. Forked from jeresig/trie-js by John Resig. | ||
|
||
## Installation | ||
|
||
$ npm install anagram | ||
|
||
## Examples | ||
|
||
```js | ||
var anagram = require('anagram'); | ||
|
||
anagram.init('../dict/twl06.js', function(err) { | ||
if (err) throw err; | ||
anagram.findAnagrams('dog', function(err, anagrams) { | ||
console.log('`%s`: found %d anagrams', anagrams.input, anagrams.count); | ||
console.log(anagrams); | ||
}); | ||
}); | ||
``` | ||
|
||
## Executables | ||
|
||
anagram comes packed with two executables: `anagram` and `anagram-build` | ||
|
||
```shell | ||
$ anagram-build -f dict/twl06.txt > dict/twl06.js | ||
|
||
$ anagram -d dict/twl06.js -w anagr?m | ||
``` | ||
|
||
## Running tests | ||
|
||
Install development dependencies: | ||
|
||
$ npm install -d | ||
|
||
Run the tests: | ||
|
||
$ npm test | ||
|
||
## License | ||
|
||
Copyright (c) 2012 Ryan Nauman | ||
|
||
MIT Licensed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
var anagram = require ('../lib/anagram'); | ||
|
||
// output anagrams with wildcard highlighting | ||
anagram.init('../dict/twl06.js', function(err) { | ||
if (err) throw err; | ||
anagram.findAnagrams('aa?', { 'format': 'md' }, function(err, anagrams) { | ||
console.log('Found %d anagrams for `%s`.', anagrams.count, anagrams.input); | ||
console.log('3 letters:'); | ||
console.log(' ' + anagrams['3']); | ||
console.log('2 letters:'); | ||
console.log(' ' + anagrams['2']); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
var anagram = require ('../lib/anagram'); | ||
|
||
// the default options with findAnagramsSafely are: | ||
// the default options with findAnagrams are: | ||
// maxWilcards: 3 | ||
anagram.init('../dict/twl06.js', function() { | ||
anagram.findAnagramsSafely('??????', function(err, anagrams) { | ||
anagram.findAnagrams('??????', function(err, anagrams) { | ||
console.log('`%s`: found %d anagrams', '??????', anagrams.count); | ||
}); | ||
anagram.findAnagramsSafely('??????', {maxWildcards: 2}, function(err, anagrams) { | ||
anagram.findAnagrams('??????', {maxWildcards: 2}, function(err, anagrams) { | ||
console.log('`%s`: found %d anagrams', '??????', anagrams.count); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters