{"id":17291908,"url":"https://github.com/fergiemcdowall/stopword","last_synced_at":"2025-05-14T23:04:44.367Z","repository":{"id":32856299,"uuid":"36450024","full_name":"fergiemcdowall/stopword","owner":"fergiemcdowall","description":"A module for node.js and the browser that takes in text and strips it of stopwords","archived":false,"fork":false,"pushed_at":"2024-12-30T09:24:15.000Z","size":3727,"stargazers_count":249,"open_issues_count":5,"forks_count":35,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-05-13T13:19:22.482Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fergiemcdowall.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-05-28T16:02:55.000Z","updated_at":"2025-05-12T00:44:40.000Z","dependencies_parsed_at":"2023-01-16T23:15:16.240Z","dependency_job_id":"f6aa63aa-2c44-4e63-a143-571b4f589fa8","html_url":"https://github.com/fergiemcdowall/stopword","commit_stats":{"total_commits":441,"total_committers":23,"mean_commits":19.17391304347826,"dds":0.3650793650793651,"last_synced_commit":"08f73542f6f2246e9f300fd0f4489386ac1d0c5b"},"previous_names":[],"tags_count":47,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fergiemcdowall%2Fstopword","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fergiemcdowall%2Fstopword/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fergiemcdowall%2Fstopword/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fergiemcdowall%2Fstopword/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fergiemcdowall","download_url":"https://codeload.github.com/fergiemcdowall/stopword/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253948511,"owners_count":21988962,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-15T10:42:13.474Z","updated_at":"2025-05-14T23:04:39.352Z","avatar_url":"https://github.com/fergiemcdowall.png","language":"JavaScript","funding_links":[],"categories":["🔧 Utilities \u0026 Miscellaneous"],"sub_categories":[],"readme":"# stopword\n\n`stopword` is a module for node and the browser that allows you to strip\nstopwords from an input text. Covers 62 languages. [In natural language processing, \"Stopwords\" are words that are so frequent that they can safely be removed from a text without altering its meaning.](https://en.wikipedia.org/wiki/Stop_words)\n\nAll `.min` minified files are approximately 130 Kb each.\n\n[![NPM version][npm-version-image]][npm-url]\n[![NPM downloads][npm-downloads-image]][npm-url]\n[![jsDelivr downloads](https://data.jsdelivr.com/v1/package/npm/stopword/badge?style=rounded)](https://www.jsdelivr.com/package/npm/stopword)\n[![Build Status][CI-image]][CI-url]\n[![JavaScript Style Guide][standardjs-image]][standardjs-url]\n[![MIT License][license-image]][license-url]\n\n[![wonderful day stopword module](https://github.com/fergiemcdowall/stopword/raw/main/demo/stopword-demo.gif)](https://fergiemcdowall.github.io/stopword/demo/)\n\nLive [stopword browser demo](https://fergiemcdowall.github.io/stopword/demo/)\n\n## Breaking change!\n\nLanguage codes are changed from `ISO-639-1` (two characters) to `ISO-639-3` (three characters). This to have room for more small languages that wasn't specified in `ISO-639-1`.\n\nIf you haven't specified any stopword lists and just gone with the default (which is English), it should continue working without the need for any change.\n\n## Getting the script in your environment\n\n### CJS - CommonJS\n\nDeconstruction require:\n```javascript\nconst { removeStopwords, eng, fra } = require('stopword')\n// 'removeStopwords', 'eng' and 'fra' available\n```\n\nOld style require:\n```javascript\nconst sw = require('stopword')\n// sw.removeStopwords and sw.\u003clanguage codes\u003e now available\n```\n\n### ESM - Ecmascript Modules\nDeconstruction import:\n```javascript\nimport { removeStopwords, eng, fra } from './dist/stopword.esm.mjs'\n// 'removeStopwords', 'eng' and 'fra' available\n```\n\nOld style import:\n```javascript\nimport * as sw from './dist/stopword.esm.mjs'\n// 'sw.removeStopwords' + 'sw.\u003clanguage codes\u003e' available\n```\n\n### UMD - Script tag method\n\n```html\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/stopword/dist/stopword.umd.min.js\"\u003e\u003c/script\u003e\n\n\u003cscript\u003e\n// sw.removeStopwords and sw.\u003clanguage codes\u003e now available\n\u003c/script\u003e\n```\n\n### TypeScript\n\n#### TypeScript with CJS\n```ts\nimport * as sw from 'stopword'\n// 'sw.removeStopwords' + 'sw.\u003clanguage codes\u003e' available\n```\n\n#### TypeScript with ESM\n```ts\nimport { removeStopwords, eng, fra } from 'stopword'\n// 'removeStopwords', 'eng' and 'fra' available\n```\n\n#### Install TypeScript types\n`npm i @types/stopword --save-dev`\n\n## Usage\n\n### Default (English)\n\nBy default, `stopword` will strip an array of \"meaningless\" English words\n\n```javaScript\nconst { removeStopwords } = require('stopword')\nconst oldString = 'a really Interesting string with some words'.split(' ')\nconst newString = removeStopwords(oldString)\n// newString is now [ 'really', 'Interesting', 'string', 'words' ]\n\n```\n\n### Other languages\n\nYou can also specify a language other than English:\n```javaScript\nconst { removeStopwords, swe } = require('stopword')\nconst oldString = 'Trädgårdsägare är beredda att pröva vad som helst för att bli av med de hatade mördarsniglarna åäö'.split(' ')\n// swe contains swedish stopwords\nconst newString = removeStopwords(oldString, swe)\n// newString is now [ 'Trädgårdsägare', 'beredda', 'pröva', 'helst', 'hatade', 'mördarsniglarna', 'åäö' ]\n```\n\n### Numbers\n\nExtract numbers (korean script/characters) with module `words-n-numbers` and removing 0-9 'stopwords'\n\n```javaScript\nconst { removeStopwords, _123 } = require('stopword')\nconst { extract, words, numbers } = require('words-n-numbers')\nconst oldString = '쾰른 대성당(독일어: Kölner Dom, 정식 명칭: Hohe Domkirche St. Peter)은 독일 쾰른에 있는 로마 가톨릭교회의 성당이다. 고딕 양식으로 지어졌다. 쾰른 대교구의 주교좌 성당이라 쾰른 주교좌 성당이라고도 불린다. 현재 쾰른 대교구의 교구장은 라이너 마리아 뵐키 추기경이다. 이 성당은 독일에서 가장 잘 알려진 건축물로, 성 바실리 대성당에 이어, 1996년 유네스코 세계유산으로 등재되었다. 유네스코에서는 쾰른 대성당을 일컬어 “인류의 창조적 재능을 보여주는 드문 작품”이라고 묘사하였다.[1] 매일 2만여 명의 관광객이 이 성당을 찾는다.[2]'\nlet newString = extract(oldString, { regex: [numbers] })\nnewString = removeStopwords(newString, _123)\n// newString is now [ '1996' ]\n})\n```\n\n### Custom list of stopwords\n\nAnd last, but not least, it is possible to use your own, custom list of stopwords:\n```javascript\nconst { removeStopwords } = require('stopword')\nconst oldString = 'you can even roll your own custom stopword list'.split(' ')\n// Just add your own list/array of stopwords\nconst newString = removeStopwords(oldString, [ 'even', 'a', 'custom', 'stopword', 'list', 'is', 'possible']\n// newString is now [ 'you', 'can', 'roll', 'your', 'own']\n```\n\n### Removing stopwords for i.e. two languages and a custom stopword list\n\nWith spread syntax you can easily combine several stopword arrays into one. Useful for situations where two langauages are used interchangeably. Or when you have certain words that are used in every document that is not in your existing stopword arrays.\n```javascript\nconst { removeStopwords, eng, swe } = require('stopword')\nconst oldString = 'a really interesting string with some words trädgårdsägare är beredda att pröva vad som helst för att bli av med de hatade mördarsniglarna'.split(' ')\nconst customStopwords = ['interesting', 'really']\nconst newString = sw.removeStopwords(oldString, [...eng, ...swe, ...customStopwords]\n// newString is now ['string', 'words', 'trädgårdsägare', 'beredda', 'pröva', 'helst', 'hatade', 'mördarsniglarna']\n```\n\n\n## API\n\n### removeStopwords\n\nReturns an Array that represents the text with the specified stopwords removed.\n\n* `text` An array of words\n* `stopwords` An array of stopwords\n\n```javascript\nconst { removeStopwords } = require('stopword')\nvar text = removeStopwords(text[, stopwords])\n// text is now an array of given words minus specified stopwords\n```\n\n### \u0026lt;language code\u0026gt;\n\nLanguage codes follow [ISO 639-3 Language Code list](https://iso639-3.sil.org/code_tables/639/data/all). Arrays of stopwords for the following 62 languages are supplied:\n\n* `_123` - 0-9 for different script (regular, Farsi, Korean and Myanmar)\n* `afr` - Afrikaans\n* `ara` - Arabic, Macrolanguage\n* `hye` - Armenian\n* `eus` - Basque\n* `ben` - Bengali\n* `bre` - Breton\n* `bul` - Bulgarian\n* `cat` - Catalan, Valencian \n* `zho` - Chinese, Macrolanguage\n* `hrv` - Croatian\n* `ces` - Czech\n* `dan` - Danish\n* `nld` - Dutch\n* `eng` - English\n* `epo` - Esperanto\n* `est` - Estonian, Macrolanguage\n* `fin` - Finnish\n* `fra` - French\n* `glg` - Galician\n* `deu` - German\n* `ell` - Greek, Modern\n* `guj` - Gujarati\n* `hau` - Hausa\n* `heb` - Hebrew\n* `hin` - Hindi\n* `hun` - Hungarian\n* `ind` - Indonesian\n* `gle` - Irish\n* `ita` - Italian\n* `jpn` - Japanese\n* `kor` - Korean\n* `kur` - Kurdish, Macrolanguage\n* `lat` - Latin\n* `lav` - Latvian, Macrolanguage\n* `lit` - Lithuanian\n* `lgg` - Lugbara\n* `lggNd` - Lugbara, No diacritics\n* `msa` - Malay, Macrolanguage\n* `mar` - Marathi\n* `mya` - Myanmar (Burmese)\n* `nob` - Norwegian bokmål\n* `fas` - Persian (Farsi)\n* `pol` - Polish\n* `por` - Portuguese\n* `porBr` - Portuguese-Brazilian\n* `panGu` - Punjabi (Panjabi), Gurmukhi script\n* `ron` - Romanian (Moldavian, Moldovan)\n* `rus` - Russian\n* `slk` - Slovak\n* `slv` - Slovenian\n* `som` - Somali\n* `sot` - Sotho, Southern\n* `spa` - Spanish\n* `swa` - Swahili, Macrolanguage\n* `swe` - Swedish\n* `tgl` - Tagalog (Filipino)\n* `tha` - Thai\n* `tur` - Turkish\n* `ukr` - Ukrainian\n* `urd` - Urdu\n* `vie` - Vietnamese\n* `yor` - Yoruba\n* `zul` - Zulu\n\n#### Languages with no space between words\n\n`jpn` Japanese, `tha` Thai and `zho` Chinese 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 [SudachiPy](https://github.com/WorksApplications/sudachi.rs/tree/develop/python), [TinySegmenter](https://chasen.org/%7Etaku/software/TinySegmenter/) for Japanese and [chinese-tokenizer](https://github.com/yishn/chinese-tokenizer), [jieba](https://github.com/fxsjy/jieba), [pkuseg](https://github.com/lancopku/pkuseg-python) for Chinese.\n\n## Your language missing?\n\nIf you can't find a stopword file for your language, you can try creating one with [`stopword-trainer`](https://github.com/eklem/stopword-trainer). We're happy to help you in the process.\n\n## Contributions and licenses\n\nMost of this work is from other projects and people, and wouldn't be possible without them. Thanks to among others the [stopwords-iso](https://github.com/stopwords-iso) project and the [more-stoplist](https://github.com/dohliam/more-stoplists) project. And thanks for all your code input: [@arthurdenner](https://github.com/arthurdenner), [@micalevisk](https://github.com/micalevisk), [@fabric-io-rodrigues](https://github.com/fabric-io-rodrigues), [@behzadmoradi](https://github.com/behzadmoradi), [@guysaar223](https://github.com/guysaar223), [@ConnorKrammer](https://github.com/ConnorKrammer), [@GreXLin85](https://github.com/GreXLin85), [@nanopx](https://github.com/nanopx), [@virtual](https://github.com/virtual), [@JustroX](https://github.com/JustroX), [@DavideViolante](https://github.com/DavideViolante), [@rodfeal](https://github.com/rodfeal), [@BLKSerene](https://github.com/BLKSerene), [@dsdenes](https://github.com/dsdenes), [msageryd](https://github.com/msageryd), [imposeren](https://github.com/imposeren) and [laygir](https://github.com/laygir)!\n\n[Licenses](./dist/3rd-party.txt) for this library and all third party code.\n\n[license-image]: https://img.shields.io/badge/license-MIT-blue.svg?style=flat\n[license-url]: LICENSE\n[npm-url]: https://npmjs.org/package/stopword\n[npm-version-image]: https://img.shields.io/npm/v/stopword.svg?style=flat\n[npm-downloads-image]: https://img.shields.io/npm/dm/stopword.svg?style=flat\n[CI-url]: https://github.com/fergiemcdowall/stopword/actions/workflows/tests.yml\n[CI-image]: https://github.com/fergiemcdowall/stopword/actions/workflows/tests.yml/badge.svg\n[standardjs-url]: https://standardjs.com\n[standardjs-image]: https://img.shields.io/badge/code_style-standard-brightgreen.svg?style=rounded\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffergiemcdowall%2Fstopword","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffergiemcdowall%2Fstopword","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffergiemcdowall%2Fstopword/lists"}