How to use wuzzy - 3 common examples

To help you get started, we’ve selected a few wuzzy 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 postlight / mercury-parser / src / cleaners / resolve-split-title.js View on Github external
function cleanDomainFromTitle(splitTitle, url) {
  // Search the ends of the title, looking for bits that fuzzy match
  // the URL too closely. If one is found, discard it and return the
  // rest.
  //
  // Strip out the big TLDs - it just makes the matching a bit more
  // accurate. Not the end of the world if it doesn't strip right.
  const { host } = URL.parse(url);
  const nakedDomain = host.replace(DOMAIN_ENDINGS_RE, '');

  const startSlug = splitTitle[0].toLowerCase().replace(' ', '');
  const startSlugRatio = wuzzy.levenshtein(startSlug, nakedDomain);

  if (startSlugRatio > 0.4 && startSlug.length > 5) {
    return splitTitle.slice(2).join('');
  }

  const endSlug = splitTitle
    .slice(-1)[0]
    .toLowerCase()
    .replace(' ', '');
  const endSlugRatio = wuzzy.levenshtein(endSlug, nakedDomain);

  if (endSlugRatio > 0.4 && endSlug.length >= 5) {
    return splitTitle.slice(0, -2).join('');
  }

  return null;
github postlight / mercury-parser / src / cleaners / resolve-split-title.js View on Github external
// accurate. Not the end of the world if it doesn't strip right.
  const { host } = URL.parse(url);
  const nakedDomain = host.replace(DOMAIN_ENDINGS_RE, '');

  const startSlug = splitTitle[0].toLowerCase().replace(' ', '');
  const startSlugRatio = wuzzy.levenshtein(startSlug, nakedDomain);

  if (startSlugRatio > 0.4 && startSlug.length > 5) {
    return splitTitle.slice(2).join('');
  }

  const endSlug = splitTitle
    .slice(-1)[0]
    .toLowerCase()
    .replace(' ', '');
  const endSlugRatio = wuzzy.levenshtein(endSlug, nakedDomain);

  if (endSlugRatio > 0.4 && endSlug.length >= 5) {
    return splitTitle.slice(0, -2).join('');
  }

  return null;
}
github linanqiu / lexrank / lexrank.js View on Github external
function constructMatrix(sentences, threshold) {
    var matrix = [];
    for (var i = 0; i < sentences.length; i++) {
      matrix[i] = [];

      var sentenceA = sentences[i];

      for (var j = 0; j < sentences.length; j++) {
        var sentenceB = sentences[j];
        var value = wuzzy.tanimoto(sentenceB, sentenceA);
        if(!!threshold && value < threshold) {
          value = 0;
        }
        matrix[i][j] = value;
      }

      matrix[i] = normalize(matrix[i]);
    }
    return matrix;
  }

wuzzy

library for simularity identification

MIT
Latest version published 3 years ago

Package Health Score

47 / 100
Full package analysis

Popular wuzzy functions