retext-soundex
Retext implementation of the Soundex algorithm.
Installation
npm:
npm install retext-soundex
retext-soundex is also available for bower, component, and duo, and as an AMD, CommonJS, and globals module, uncompressed and compressed.
Usage
var retext = ;var inspect = ;var soundex = ; ;
Yields:
RootNode[1]└─ ParagraphNode[1] └─ SentenceNode[8] ├─ WordNode[1] [data={"phonetics":"A000"}] │ └─ TextNode: 'A' ├─ WhiteSpaceNode: ' ' ├─ WordNode[1] [data={"phonetics":"S514"}] │ └─ TextNode: 'simple' ├─ WhiteSpaceNode: ' ' ├─ WordNode[1] [data={"phonetics":"E524"}] │ └─ TextNode: 'English' ├─ WhiteSpaceNode: ' ' ├─ WordNode[1] [data={"phonetics":"S535"}] │ └─ TextNode: 'sentence' └─ PunctuationNode: '.'
You can also combine it with a stemmer (such as retext-porter-stemmer or retext-lancaster-stemmer).
var retext = ;var inspect = ;var soundex = ;var stemmer = ; ;
Yields:
RootNode[1]└─ ParagraphNode[1] └─ SentenceNode[6] ├─ WordNode[1] [data={"stem":"a","phonetics":"A000","stemmedPhonetics":"A000"}] │ └─ TextNode: 'A' ├─ WhiteSpaceNode: ' ' ├─ WordNode[1] [data={"stem":"detest","phonetics":"D323","stemmedPhonetics":"D323"}] │ └─ TextNode: 'detestable' ├─ WhiteSpaceNode: ' ' ├─ WordNode[1] [data={"stem":"paragraph","phonetics":"P626","stemmedPhonetics":"P6261"}] │ └─ TextNode: 'paragraph' └─ PunctuationNode: '.'
API
None, retext-soundex automatically detects the phonetics of each
WordNode
(using wooorm/soundex-code),
and stores the phonetics in node.data.phonetics
. If a stemmer is used,
the stemmed phonetics are stored in node.data.stemmedPhonetics
.