Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

stopword

Package Overview
Dependencies
Maintainers
2
Versions
72
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stopword

A module for node.js and the browser that takes in text and returns text that is stripped of stopwords. Has pre-defined stopword lists for 54 languages and also takes lists with custom stopwords as input.

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
67K
decreased by-6.1%
Maintainers
2
Weekly downloads
 
Created
Source

stopword

stopword is a module for node and the browser that allows you to strip stopwords from an input text. In natural language processing, "Stopwords" are words that are so frequent that they can safely be removed from a text without altering its meaning.

NPM version NPM downloads MIT License Build Status

wonderful day stopword module

Live stopword browser demo.

Usage

Node.js

sw = require('stopword')
// sw.removeStopwords and sw.[language code] now available

Script tag method

<script src="stopword.js"></script>

<script>
// sw.removeStopwords and sw.[language code] now available
</script>

Default (English)

By default, stopword will strip an array of "meaningless" English words

sw = require('stopword')
const oldString = 'a really Interesting string with some words'.split(' ')
const newString = sw.removeStopwords(oldString)
// newString is now [ 'really', 'Interesting', 'string', 'words' ]

Other languages

You can also specify a language other than English:

sw = require('stopword')
const oldString = 'Trädgårdsägare är beredda att pröva vad som helst för att bli av med de hatade mördarsniglarna åäö'.split(' ')
// sw.sv contains swedish stopwords
const newString = sw.removeStopwords(oldString, sw.sv)
// newString is now [ 'Trädgårdsägare', 'beredda', 'pröva', 'helst', 'hatade', 'mördarsniglarna', 'åäö' ]

Custom list of stopwords

And last, but not least, it is possible to use your own, custom list of stopwords:

sw = require('stopword')
const oldString = 'you can even roll your own custom stopword list'.split(' ')
// Just add your own list/array of stopwords
const newString = sw.removeStopwords(oldString, [ 'even', 'a', 'custom', 'stopword', 'list', 'is', 'possible']
// newString is now [ 'you', 'can', 'roll', 'your', 'own']

API

removeStopwords

Returns an Array that represents the text with the specified stopwords removed.

  • text An array of words
  • stopwords An array of stopwords
sw = require('stopword')
var text = sw.removeStopwords(text[, stopwords])
// text is now an array of given words minus specified stopwords

<language code>

Arrays of stopwords for the following 54 languages are supplied:

  • af - Afrikaans
  • ar - Arabic, Modern Standard
  • hy - Armenian
  • eu - Basque
  • bn - Bengali
  • br - Breton
  • bg - Bulgarian
  • ca - Catalan
  • zh - Chinese Simplified
  • hr - Croatian
  • cs - Czech
  • da - Danish
  • nl - Dutch
  • en - English
  • eo - Esperanto
  • et - Estonian
  • fa - Farsi
  • fi - Finnish
  • fr - French
  • gl - Galician
  • de - German
  • el - Greek
  • ha - Hausa
  • he - Hebrew
  • hi - Hindi
  • hu - Hungarian
  • id - Indonesian
  • ga - Irish
  • it - Italian
  • ja - Japanese
  • ko - Korean
  • la - Latin
  • lv - Latvian
  • lgg - Lugbara (without diacritics)
  • lggo - Lugbara official (with diacritics)
  • mr - Marathi
  • no - Norwegian
  • pl - Polish
  • pt - Portuguese
  • ptbr - Portuguese (Brazilian)
  • pa - Punjabi Gurmukhi
  • ro - Romanian
  • ru - Russian
  • sk - Slovak
  • sl - Slovenian
  • so - Somali
  • st - Sotho
  • es - Spanish
  • sw - Swahili
  • sv - Swedish
  • th - Thai
  • tr - Turkish
  • vi - Vietnamese
  • yo - Yoruba
  • zu - Zulu
sw = require('stopword')
norwegianStopwords = sw.no
// norwegianStopwords now contains an Array of norwgian stopwords
Languages with no space between words

ja Japanese, th Thai and zh Chinese Simplified and some of the other languages supported have no space between words. For these languages you need to split the text into an array of words in another way than just textString.split(' '). You can check out TinySegmenter for Japanese and chinese-tokenizer for Chinese.

Your language missing?

If you can't find a stopword file for your language, you can try creating one with stopword-trainer. We're happy to help you in the process.

Keywords

FAQs

Package last updated on 22 Apr 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc