How to use the natural.DoubleMetaphone function in natural

To help you get started, we’ve selected a few natural examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github NaturalNode / natural / examples / phonetics / tokenize_and_phoneticize.js View on Github external
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

var natural = require('natural'),
    phonetic = natural.DoubleMetaphone;

var sentence = 'phonetic modules contain algorithms';
var stdin = process.openStdin();
stdin.setEncoding('ascii');
phonetic.attach();
process.stdout.write('enter a word that sounds like one of these, "' + sentence +'": ');

words = sentence.tokenizeAndPhoneticize();

function findMatch(input) {
    inputSounds = input.phonetics();
    console.log(inputSounds);
    
    for(var i = 0; i < words.length; i++) {
	wordSounds = words[i];
github words / double-metaphone / benchmark.js View on Github external
*/

var doubleMetaphone;

doubleMetaphone = require('./');

/*
 * Optional dependencies.
 */

var natural,
    doublemetaphone,
    exception;

try {
    natural = require('natural').DoubleMetaphone;
    natural = natural.process.bind(natural);
} catch (error) {
    exception = error;
}

try {
    doublemetaphone = new (require('doublemetaphone'))();
    doublemetaphone.setMaxCodeLen(Infinity);
    doublemetaphone = doublemetaphone.doubleMetaphone.bind(doublemetaphone);
} catch (error) {
    exception = error;
}

if (exception) {
    console.log(
        '\u001B[0;31m' +

natural

General natural language (tokenizing, stemming (English, Russian, Spanish), part-of-speech tagging, sentiment analysis, classification, inflection, phonetics, tfidf, WordNet, jaro-winkler, Levenshtein distance, Dice's Coefficient) facilities for node.

MIT
Latest version published 1 month ago

Package Health Score

98 / 100
Full package analysis