How to use the natural.Metaphone 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 eugeneware / levels / lib / levels.js View on Github external
/*!
 * levels
 * Copyright(c) 2013 Eugene Ware 
 * MIT Licensed
 */

/**
 * Module dependencies.
 */

var natural = require('natural')
  , metaphone = natural.Metaphone.process
  , stem = natural.PorterStemmer.stem
  , stopwords = natural.stopwords
  , sublevel = require('level-sublevel')
  , _ = require('underscore')
  , async = require('async')
  , byteup = require('byteup')
  , noop = function(){};

/* Add bytewise encoding */
byteup();

/**
 * Library version.
 */

exports.version = '0.0.3';
github sxyizhiren / cn-search / lib / reds.js View on Github external
/*!
 * reds
 * Copyright(c) 2011 TJ Holowaychuk 
 * cn-search
 * Copyright(c) 2013 Sxyizhiren <786647787@qq.com>
 * MIT Licensed
 */

/**
 * Module dependencies.
 */

var natural = require('natural');
var metaphone = natural.Metaphone.process;
var stem = natural.PorterStemmer.stem;
var stopwords = natural.stopwords;
var cnstopwords = require('./cnstopWords');

// default chinese segment
var Segment = require('segment').Segment;
var segment = new Segment();
segment.useDefault();

/**
 * Chinese Segment
 * @type {*}
 */
var segmentSync = function(str){
    var words=segment.doSegment(str);
    var result=[];
github NaturalNode / natural / examples / phonetics / compare.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.Metaphone;

var wordA = 'phonetics';
var stdin = process.openStdin();
stdin.setEncoding('ascii');

process.stdout.write('try to enter a word that sounds like "' + wordA +'": ');

stdin.on('data', function (wordB) {
	if(phonetic.compare(wordA, wordB))
	    process.stdout.write('they sound alike!\n');
	else
	    process.stdout.write('sorry, they don\'t sound alike.\n');

	process.exit();
    });
github words / metaphone / benchmark.js View on Github external
words,
    natural,
    metafone;

/*
 * Module dependencies.
 */

metaphone = require('./');

/*
 * Optional dependencies.
 */

try {
    natural = require('natural').Metaphone;
    metafone = require('./node_modules/metafone/metafone.js').convert;
} catch (error) {
    console.log(
        '\u001B[0;31m' +
        '  The libraries needed by this benchmark could not be found. ' +
        '  Please execute:\n' +
        '    npm run install-benchmark\n' +
        '\u001B[0m'
    );
}

/*
 * The first 1000 words from Letterpress:
 *   https://github.com/atebits/Words
 */
github NaturalNode / natural / examples / phonetics / sounds_like.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.Metaphone;

phonetic.attach();
var wordA = 'phonetics';
var stdin = process.openStdin();
stdin.setEncoding('ascii');

process.stdout.write('try to enter a word that sounds like "' + wordA +'": ');

stdin.on('data', function (wordB) {
	if(wordA.soundsLike(wordB))
	    process.stdout.write('they sound alike!\n');
	else
	    process.stdout.write('sorry, they don\'t sound alike.\n');
	
	process.exit();
    });
github phillro / mongoose-fulltext / lib / search.js View on Github external
/**
 * User: philliprosen
 * Date: 1/1/13
 * Time: 3:10 PM
 */
var natural = require('natural'),
    metaphone = natural.Metaphone,
    NGrams = natural.NGrams,
    TfIdf = natural.TfIdf;

metaphone.attach()

exports.Search = Search;

function Search(key, options) {
    var options = options || {};
    this.key = key;

    this.stopwords=options.stopwords ? options.stopwords : false;
    this.stopwords=options.naturalstop ? natural.stopwords : false;


}
github tj / reds / lib / reds.js View on Github external
/*!
 * reds
 * Copyright(c) 2011 TJ Holowaychuk 
 * MIT Licensed
 */

/**
 * Module dependencies.
 */

var natural = require('natural');
var metaphone = natural.Metaphone.process;
var stem = natural.PorterStemmer.stem;
var stopwords = natural.stopwords;
var redis = require('redis');
function noop(){};

/**
 * Library version.
 */

exports.version = '1.0.0';

/**
 * Expose `Search`.
 */

exports.Search = Search;
github eugeneware / fulltext-engine / nlp.js View on Github external
function metaphoneArray(words) {
  var arr = []
    , constant;
  for (var i = 0, len = words.length; i < len; ++i) {
    constant = natural.Metaphone.process(words[i]);
    if (!~arr.indexOf(constant)) arr.push(constant);
  }
  return arr;
}
github jloveric / SentenceSimilarity / SimilarityScore.js View on Github external
let metaphoneDl = function(a, b, options) {
  let scoreDl = dlev(a, b).similarity;
  let scoreSoundex = 0;

  if (natural.Metaphone.compare(a, b)) {
    scoreSoundex = 1;
  }

  //let score = 0.5 * (scoreDl + scoreSoundex);
  let score = 0.5 * (scoreDl + scoreSoundex);
  if (score < options.threshold) score = 0.0;
  return score;
};

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