npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

word-overlap

v2.4.1

Published

overlap of words in a sentence or phrase to determine whether they are referring to the same context

Downloads

174

Readme

#word-overlap

NPM version Build Status Coverage Status Code Climate Dependency Status

Check the number of words overlapping between 2 phrases or sentences

Used in cases to check whether 2 titles / sentences / phrases are referring to the same context. E.g. 2 event names.

##Install

  1. with npm

    npm install word-overlap
  • with browserify
    1. in file main.js

      // in main.js
      var overlap = require('word-overlap');
      
      var sentence1 = 'The Hitchhikings Meetup in Betelgeuse by Ford Prefect';
      var sentence2 = 'The hitchhikings meetups by the hitchhikers';
      
      var reply = overlap(sentence1, sentence2, {
        ignoreCase: true,
        minWordLength: 2,
        ignoreCommonWords: true
      });
      
      console.log(reply);
    • in file index.html

      <script src="build.js"></script>
    • make the file build.js

      browserify main.js -o build.js --exclude WNdb --exclude lapack

##Usage

var overlap = require('word-overlap');

var sentence1 = 'The Hitchhikings Meetup in Betelgeuse by Ford Prefect';
var sentence2 = 'The hitchhikings meetups by the hitchhikers';

###simple case

overlap(sentence1, sentence2);
// [ 'The', 'by' ]

###option: ignore case

overlap(sentence1, sentence2, {
   ignoreCase: true
});
// [ 'the', 'hitchhikings', 'by' ]

###option: min word length

overlap(sentence1, sentence2, {
  ignoreCase: true,
  minWordLength: 2
});
// [ 'the', 'hitchhiking', 'by' ]

###option: ignore default common words

Common words by default include: a, an, the, this, that, there, it, in, on, for, not, your, you, at, to, is, us, out, by, I

overlap(sentence1, sentence2, {
  ignoreCase: true,
  minWordLength: 2,
  ignoreCommonWords: true
});
// [ 'hitchhikings' ]

###option: ignore number

Ignore numbers such as: 5e3, 0xff, -1.1, 0, 1, 1.1, 10, 10.10, 100, '-1.1', etc.

sentence1 = 'Welcome to 2015';
sentence2 = '2015 Meetup for the year';
console.log(overlap(sentence1, sentence2, {
  ignoreNumber: true
}));
// [ ]

###option: add your common words to ignore

overlap(sentence1, sentence2, {
  ignoreCase: true,
  minWordLength: 2,
  ignoreCommonWords: true,
  common: [ 'hitchhikings' ]
});
// [ ]

###option: depluralize words

overlap(sentence1, sentence2, {
  ignoreCase: true,
  minWordLength: 2,
  ignoreCommonWords: true,
  depluralize: true
});
// [ 'hitchhiking', 'meetup' ]

###option: depluralize words with plurals to ignore

overlap(sentence1, sentence2, {
  ignoreCase: true,
  minWordLength: 2,
  ignoreCommonWords: true,
  depluralize: true,
  ignorePlurals: [ 'hitchhikings' ]
});
// [ 'hitchhikings', 'meetup' ]

###option: stemming

var sentence1 = 'A programming course in SmallTalk';
var sentence2 = 'Have you programmed in SmallTalk?';

overlap(sentence1, sentence2, {
  stemming: true,
  ignoreCommonWords: true
});
// [ 'program', 'smalltalk' ]

Try out the examples in file example.js with the command node example.js

##Contribute

Please see CONTRIBUTING.md for details.

##Versioning

This repository follows the Semantic Versioning guidelines:

  1. For patches, run grunt bump
  • For minor release, run grunt bump:minor
  • For major release, run grunt bump:major

##License

(C) Sayanee Basu 2014, released under an MIT license