How to use the natural.JaroWinklerDistance 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 psirenny / node-google-speech-api / test / index.js View on Github external
function test(err, results) {
    t.error(err);
    t.equal(typeof results, 'object');
    t.equal(typeof results[0], 'object');
    t.equal(typeof results[0].result, 'object');
    var sentence = _.reduce(results, combine, '');
    var distance = natural.JaroWinklerDistance(sentence, text);
    t.equal(distance >= opts.accuracy, true);
  };
github soyuka / explorer / lib / search / native.js View on Github external
return true

    //if search has no uppercased letters, it'll be case insensitive
    let smartcase = !/[A-Z]+/.test(search)

    if(isGlob(search)) {
      return mm(path.path, search.split(' '), {matchBase: true, nocase: smartcase}).length > 0
    }

    if(smartcase) {
      name = name.toLowerCase() 
    }
  
    name = sanitize(name)

    if(natural.JaroWinklerDistance(name, search) > options.maxScore) {
      return true 
    }

    return false
  }
}
github vishwajeetv / twitter-sentiment-analysis / twitter / api / services / WordAnalysisService.js View on Github external
function checkMatch(element, index, words) {
            return  natural.JaroWinklerDistance(word,element) > 0.8;
        }
github Capevace / halbert / system / modules / switch / actions.js View on Github external
.reduce((bestHotword, hotword) => {
          const distance = JaroWinklerDistance(switchName, hotword);
          if (!bestHotword || distance > bestHotword.distance) {
            return {
              distance,
              hotword
            };
          }
          return bestHotword;
        }, null);
github alfonsogoberjr / knearest / adapters / mongo.js View on Github external
_.forEach(this.features, (prop, name) => {
                      let delta = 0;
                      if (node.features[name] && _node.features[name] && (typeof node.features[name] === 'number') && (typeof _node.features[name] === 'number') && (this.features[name].range !== 0)) {
                        let difference = 0;
                        if (_node.features[name] > node.features[name]) difference = _node.features[name] - node.features[name]
                        else if (node.features[name] > _node.features[name]) difference = node.features[name] - _node.features[name]
                        delta = difference / (prop.max - prop.min);
                        let feature = Math.sqrt(delta * delta);
                        features.push(feature);
                      }
                      else if (node.features[name] && _node.features[name] && (typeof node.features[name] === 'string') && (typeof _node.features[name] === 'string') && (this.features[name].range !== 0)) {
                        if (this.stringAlgorithm === 'Jaro-Winkler') delta = natural.JaroWinklerDistance(node.features[name], _node.features[name]);
                        if (this.stringAlgorithm === 'Levenshtein') delta = natural.LevenshteinDistance(node.features[name], _node.features[name]);
                        if (this.stringAlgorithm === 'Dice') delta = natural.DiceCoefficient(node.features[name], _node.features[name]);
                        let feature = Math.sqrt(delta * delta);
                        features.push(feature);
                      }
                    });
                    arc.distance = features.length > 1 ? features.reduce((x, y) => x + y) : features[0];
github Capevace / halbert / system / modules / switch / actions.js View on Github external
.reduce((best, switchConfig) => {

      if (!switchConfig.hotwords) {
        const distance = JaroWinklerDistance(switchName, switchConfig.id);

        if (!best || distance > best.distance) {
          return {
            distance,
            hotword: switchConfig.id,
            config: switchConfig
          };
        }

        return best;
      }

      const result = switchConfig.hotwords
        .reduce((bestHotword, hotword) => {
          const distance = JaroWinklerDistance(switchName, hotword);
          if (!bestHotword || distance > bestHotword.distance) {
github Capevace / halbert / system / moduleRegistry / built-in / switch / actions.js View on Github external
(bestHotword, hotword) => {
            const distance = JaroWinklerDistance(switchName, hotword);
            if (!bestHotword || distance > bestHotword.distance) {
              return {
                distance,
                hotword
              };
            }
            return bestHotword;
          },
          null
github Capevace / halbert / system / moduleRegistry / built-in / switch / actions.js View on Github external
(best, switchConfig) => {
        if (!switchConfig.hotwords) {
          const distance = JaroWinklerDistance(switchName, switchConfig.id);

          if (!best || distance > best.distance) {
            return {
              distance,
              hotword: switchConfig.id,
              config: switchConfig
            };
          }

          return best;
        }

        const result = switchConfig.hotwords.reduce(
          (bestHotword, hotword) => {
            const distance = JaroWinklerDistance(switchName, hotword);
            if (!bestHotword || distance > bestHotword.distance) {

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