multi-stopwords

stopwords for multiple languages.

Usage no npm install needed!

<script type="module">
  import multiStopwords from 'https://cdn.skypack.dev/multi-stopwords';
</script>

README

Get Stopwords formultiple languages

npm install multi-stopwords

Example

var stop_words=require('multi-stopwords')(['en','sw']);

Usually, we use stopwords lists to remove stopwords from lists and arrays. Below is an example of how you would remove stopwords from a list (array).

var stop_words=require('./node_modules/seosummary/node_modules/multi-stopwords')(['en','sw'])
    , _ = require('lodash');

//Note: This is not the recommended way ofd extracting words from a string. 
//Use better 'word boundary' methods 

var words='This is a long string with some stopwords like me, zero and the Swahili words sisi, mimi and wao'.replace(/,/g,'').split(' ');

words=_.filter(words,function(n){
        console.log(n);
        return (_.indexOf(stop_words,n.toLowerCase())==-1);
});

console.log(words);

//Outputs: [ 'long', 'string', 'stopwords', 'Swahili', 'words' ]

This class is simple and the example above makes the following assumptions:

  • That the stipulated dictionary files ['en','sw'] indeed exist as json files within the ./dicts folder.
  • That each word in the json dictionary is in lowercase

You can add own dictionaries but just be sure they conform to other dictionaries so that you can easily combine them when loading stopwords.