word-overlap
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
-
with npm
npm install word-overlap
- with browserify
-
in file
main.js
// in main.jsvar overlap = ;var sentence1 = 'The Hitchhikings Meetup in Betelgeuse by Ford Prefect';var sentence2 = 'The hitchhikings meetups by the hitchhikers';var reply =;console;
-
in file
index.html
-
make the file
build.js
browserify main.js -o build.js --exclude WNdb --exclude lapack
-
Usage
var overlap = ; var sentence1 = 'The Hitchhikings Meetup in Betelgeuse by Ford Prefect';var sentence2 = 'The hitchhikings meetups by the hitchhikers';
simple case
;// [ 'The', 'by' ]
option: ignore case
;// [ 'the', 'hitchhikings', 'by' ]
option: min word length
;// [ '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
;// [ '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;// [ ]
option: add your common words to ignore
;// [ ]
option: depluralize words
;// [ 'hitchhiking', 'meetup' ]
option: depluralize words with plurals to ignore
;// [ 'hitchhikings', 'meetup' ]
option: stemming
var sentence1 = 'A programming course in SmallTalk';var sentence2 = 'Have you programmed in SmallTalk?'; ;// [ '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:
- 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