https://github.com/planeshifter/anagrams
find anagrams and similar sounding words
https://github.com/planeshifter/anagrams
Last synced: 10 months ago
JSON representation
find anagrams and similar sounding words
- Host: GitHub
- URL: https://github.com/planeshifter/anagrams
- Owner: Planeshifter
- License: mit
- Created: 2015-01-20T21:50:26.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2015-02-25T19:29:55.000Z (over 11 years ago)
- Last Synced: 2025-07-20T03:21:54.745Z (11 months ago)
- Language: JavaScript
- Size: 238 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# anagrams
find anagrams and similar sounding words
## Run the example
```js
node example.js
```
## Unit Tests
Run tests via the command `npm test`
## API
### findAnagrams(words)
For the input array of `words`, words which are anagrams are grouped together. The function returns an array of arrays, with each inner array corresponding to a set of anagrams.
Example:
```js
lib.findAnagrams( [stop, post, mundane, unarmed, manured,
unnamed]);
/*
returns
[
[ 'mundane', 'unnamed' ],
[ 'unarmed', 'manured' ],
[ 'stop', 'post' ]
]
*/
```
### findSimilarSounding(words)
Similar to `findAnagrams`, but groups together words via the *Double Metaphone*
### loadWordsFromFile(filename)
Loads synchronously a \*.txt file from disk which is assumed to have a single word on each line. The function returns an array of all the words.
### findAnagramsOf(word, anagrams)
To solve the related problem of finding all anagrams of a given word, the
function findAnagram is implemented. The second parameter `anagrams` expects
an output of `findAnagrams()`, which is used in searching for anagrams of the
supplied `word`.
Example:
```js
var words = lib.loadWordsFromFile("./data/big-wordlist.txt");
var anagrams = lib.findAnagrams(word);
lib.findAnagramsOf("spot", anagrams);
// returns [ 'stop', 'pots', 'tops', 'post', 'spot' ]
```