### Install stopwords-iso via npm Source: https://github.com/stopwords-iso/stopwords-iso/blob/master/nodejs/README.md Install the stopwords-iso package using npm. This is the primary installation method for Node/JavaScript projects. ```sh $ npm install stopwords-iso ``` -------------------------------- ### Install stopwords-iso via bower Source: https://github.com/stopwords-iso/stopwords-iso/blob/master/nodejs/README.md Install the stopwords-iso package using bower. This is an alternative installation method for front-end projects. ```sh $ bower install stopwords-iso ``` -------------------------------- ### Get English stopwords with stopwords Source: https://github.com/stopwords-iso/stopwords-iso/blob/master/python/stopwords_demo.ipynb Retrieves stopwords for a single language (English) and prints the first 10 words. ```python from stopwordsiso import stopwords words = stopwords("en") # English stopwords list(words)[:10] # print first 10 words ``` ```text Result: ['normally', 'thorough', 'down', 'ai', 'hundred', 'your', 'clear', 'ought', 'sv', 'forty'] ``` -------------------------------- ### Get stopwords for multiple languages Source: https://github.com/stopwords-iso/stopwords-iso/blob/master/python/stopwords_demo.ipynb Retrieves stopwords for multiple languages (Japanese, Thai, German) and prints the first 10 words. ```python words = stopwords(["ja", "th", "de"]) # Japanese, Thai, and German stopwords list(words)[:10] # print first 10 words ``` ```text Result: ['นี้', 'gut', 'sie', 'ihn', 'fünfter', 'manche', 'wenig', 'こちら', 'ของ', 'drei'] ``` -------------------------------- ### Install stopwordsiso via pip Source: https://github.com/stopwords-iso/stopwords-iso/blob/master/python/README.md Install the stopwordsiso package using pip. ```sh $ pip install stopwordsiso ``` -------------------------------- ### List all supported languages with langs Source: https://github.com/stopwords-iso/stopwords-iso/blob/master/python/stopwords_demo.ipynb Returns a set of all language codes supported by stopwordsiso. ```python stopwordsiso.langs() # return set of all the supported languages ``` ```text Result: {'af', 'ar', 'bg', 'bn', 'br', 'ca', 'cs', 'da', 'de', 'el', 'en', 'eo', 'es', 'et', 'eu', 'fa', 'fi', 'fr', 'ga', 'gl', 'gu', 'ha', 'he', 'hi', 'hr', 'hu', 'hy', 'id', 'it', 'ja', 'ko', 'ku', 'la', 'lt', 'lv', 'mr', 'ms', 'nl', 'no', 'pl', 'pt', 'ro', 'ru', 'sk', 'sl', 'so', 'st', 'sv', 'sw', 'th', 'tl', 'tr', 'uk', 'ur', 'vi', 'yo', 'zh', 'zu'} ``` -------------------------------- ### Using langs() to discover supported languages Source: https://github.com/stopwords-iso/stopwords-iso Example usage of `stopwords.langs()` to get the set of supported language codes and check for a specific language before fetching stopwords. Shows typical output with 58 two-letter codes. ```python import stopwordsiso as stopwords stopwords.langs() # {'af', 'ar', 'de', 'en', 'th', ...} — 58 two-letter codes # Typical use: discover supported languages, then batch-fetch supported = stopwords.langs() if "ja" in supported: jp = stopwords.stopwords("ja") ``` -------------------------------- ### Dataset record example (JSON) Source: https://github.com/stopwords-iso/stopwords-iso Human-readable equivalent of the actual minified stopwords-iso.json artifact. Shows the structure with ISO 639-1 language codes as keys and arrays of stopwords as values. ```json { "af": ["'n", "aan", "af", "al", "as", "..."], "ar": ["،", "آض", "آمينَ", "آه", "آهاً", "..."] } ``` -------------------------------- ### Import stopwordsiso Source: https://github.com/stopwords-iso/stopwords-iso/blob/master/python/stopwords_demo.ipynb Imports the stopwordsiso library to access stopwords functionality. ```python import stopwordsiso ``` -------------------------------- ### Unsupported language returns empty set Source: https://github.com/stopwords-iso/stopwords-iso/blob/master/python/stopwords_demo.ipynb Calling stopwords with an unsupported language code returns an empty set. ```python stopwords("xxx") # if the language is not supported, an empty set will be returned ``` ```text Result: set() ``` -------------------------------- ### stopwords() usage examples Source: https://github.com/stopwords-iso/stopwords-iso Examples of calling `stopwords()` with single languages, multiple languages (union of sets), unknown codes (returns empty set), and various iterables like tuples and sets. ```python from stopwordsiso import stopwords # Single language stopwords("en") # {'a', 'about', 'above', ...} stopwords("th") # {'กล่าว', 'กว่า', 'กัน', 'กับ', ...} # Multiple languages — union of sets multi = stopwords(["de", "id", "zh"]) # German + Indonesian + Chinese stopwords # Unknown language -> empty set stopwords("xxx") # set() # Any iterable works stopwords(("fr", "es")) # French + Spanish stopwords({"ja", "ko"}) # Japanese + Korean ``` -------------------------------- ### Check language support with has_lang Source: https://github.com/stopwords-iso/stopwords-iso/blob/master/python/stopwords_demo.ipynb Checks if a stopwords list exists for a given language code. Returns True if supported. ```python stopwordsiso.has_lang("th") # check if there is a stopwords list for the language ``` ```text Result: True ``` -------------------------------- ### has_lang usage examples Source: https://github.com/stopwords-iso/stopwords-iso Demonstrates calling has_lang with various language codes. Returns True for 'th' and 'en', False for 'xx' and empty string. ```python import stopwordsiso as stopwords stopwords.has_lang("th") # True — Thai stopwords.has_lang("en") # True stopwords.has_lang("xx") # False stopwords.has_lang("") # False ``` -------------------------------- ### Use stopwordsiso in Python Source: https://github.com/stopwords-iso/stopwords-iso/blob/master/README.md Import stopwordsiso and use functions like has_lang, langs, and stopwords to retrieve stopwords for various languages. Unknown languages return an empty set. ```python # Python import stopwordsiso as stopwords stopwords.has_lang("th") # check if there is a stopwords for the language stopwords.langs() # return a set of all the supported languages stopwords.stopwords("en") # English stopwords stopwords.stopwords(["de", "id", "zh"]) # German, Indonesian, and Chinese stopwords stopwords.stopwords("xxx") # an empty set will be returned for unknown language ``` -------------------------------- ### Check language support and list languages Source: https://github.com/stopwords-iso/stopwords-iso/blob/master/python/README.md Use stopwordsiso.has_lang to check if stopwords exist for a language (e.g., Thai) and stopwordsiso.langs to get a set of all supported languages. ```python import stopwordsiso stopwordsiso.has_lang("th") # check if there is a stopwords for Thai language stopwordsiso.langs() # return a set of all the supported languages ``` -------------------------------- ### Get stopwords for languages Source: https://github.com/stopwords-iso/stopwords-iso/blob/master/python/README.md Use stopwords from stopwordsiso to retrieve stopwords for one or multiple languages. Unknown languages return an empty set. ```python from stopwordsiso import stopwords stopwords("en") # English stopwords stopwords(["de", "id", "zh"]) # German, Indonesian, and Chinese stopwords stopwords("xxx") # an empty set will be returned for unknown language ``` -------------------------------- ### Module __init__.py with __version__ and __all__ Source: https://github.com/stopwords-iso/stopwords-iso Public surface of the stopwordsiso package, re-exporting has_lang, langs, and stopwords from _core. Sets __version__ to "0.6.1" and defines __all__. ```python __version__ = "0.6.1" __all__ = [ "has_lang", "langs", "stopwords", ] from ._core import has_lang, langs, stopwords ``` -------------------------------- ### TypeScript schema for StopwordsIsoRecord Source: https://github.com/stopwords-iso/stopwords-iso TypeScript rendering of the implicit schema. No .d.ts ships with the package; this is for reference only. ```typescript // TypeScript rendering of the implicit schema (no .d.ts ships with the package) type StopwordsIsoRecord = Record; ``` -------------------------------- ### langs() -> Set[str] Source: https://github.com/stopwords-iso/stopwords-iso Returns the set of all supported language codes. This is useful for iterating over available languages. ```APIDOC ## langs() -> Set[str] ### Description Returns the set of all supported language codes. This is useful for iterating over available languages. ### Returns - **Set[str]** - A set of ISO 639-1 language codes. ### Example ```python import stopwordsiso as stopwords langs = stopwords.langs() print(langs) # {'en', 'es', 'fr', ...} ``` ``` -------------------------------- ### Python typing imports Source: https://github.com/stopwords-iso/stopwords-iso The only type annotations the project's code expresses. Uses typing generics directly; there are no aliases. ```python from typing import Iterable, Set, Union ``` -------------------------------- ### Filter tokens with stopwords-iso (JavaScript) Source: https://github.com/stopwords-iso/stopwords-iso Consumes the stopwords-iso package to filter tokens. Converts the English stopword list to a Set for O(1) lookup, then filters an array of tokens. Also shows a multi-language filter combining English and German stopwords. ```javascript // Realistic consumption: filter tokens const stopwords = require('stopwords-iso'); const english = new Set(stopwords.en); // Set for O(1) lookup const tokens = ['the', 'quick', 'brown', 'fox', 'and', 'the', 'lazy', 'dog']; const content = tokens.filter(t => !english.has(t)); // ['quick', 'brown', 'fox', 'lazy', 'dog'] // Multi-language filter const multi = new Set([...stopwords.en, ...stopwords.de]); ``` -------------------------------- ### stopwords-iso (npm/Bower module) Source: https://github.com/stopwords-iso/stopwords-iso The npm/Bower module 'stopwords-iso' exports a static JSON object containing stopwords for 58 ISO 639-1 languages. The JSON file is the module's export; there is no JavaScript code. ```APIDOC ## stopwords-iso (npm/Bower module) ### Description The npm/Bower module `stopwords-iso` exports a static JSON object containing stopwords for 58 ISO 639-1 languages. The JSON file is the module's export; there is no JavaScript code. ### Export Shape - **data object** (object) - Contains 58 language keys, each mapping to an array of stopwords. ### Language Keys The dataset includes all 58 ISO 639-1 language codes. See the full list in the JSON file. ### Consumption Patterns - **npm**: `const stopwords = require('stopwords-iso');` - **Bower**: Include the JSON file directly. ### Example ```json { "en": ["a", "about", "above", ...], "es": ["un", "una", "unas", ...] } ``` ``` -------------------------------- ### Require stopwords-iso in Node.js Source: https://github.com/stopwords-iso/stopwords-iso/blob/master/nodejs/README.md Load the stopwords-iso module in Node.js. The module exports an object of stopwords for multiple languages; access a specific language's stopwords via its ISO 639-1 code (e.g., `stopwords.en` for English). ```js // Node const stopwords = require('stopwords-iso'); // object of stopwords for multiple languages const english = stopwords.en; // English stopwords ``` -------------------------------- ### CommonJS import of stopwords-iso Source: https://github.com/stopwords-iso/stopwords-iso CommonJS usage for Node.js >= 0.10.0. The module exports a data object; accessing an unknown language key returns undefined. ```javascript // CommonJS (Node.js >= 0.10.0) — documented usage const stopwords = require('stopwords-iso'); // object of stopwords for multiple languages const english = stopwords.en; // English stopwords ``` -------------------------------- ### stopwords(lang: str) -> set[str] Source: https://github.com/stopwords-iso/stopwords-iso Returns the set of stopwords for a given ISO 639-1 language code. Raises an error if the language is not supported. ```APIDOC ## stopwords(lang: str) -> set[str] ### Description Returns the set of stopwords for a given ISO 639-1 language code. Raises an error if the language is not supported. ### Method Function call ### Parameters - `lang` (str) - Required - ISO 639-1 language code. ### Returns - `set[str]` - Set of stopwords for the specified language. ``` -------------------------------- ### Python schema for StopwordsIsoRecord Source: https://github.com/stopwords-iso/stopwords-iso Python rendering of the implicit schema, inferred from json.load() at python/stopwordsiso/_core.py:16-21 and type annotations in that module. ```python # Python rendering of the implicit schema (inferred from json.load() at # python/stopwordsiso/_core.py:16-21 and type annotations in that module) StopwordsIsoRecord = Dict[str, List[str]] ``` -------------------------------- ### stopwords() error handling and robust consumer pattern Source: https://github.com/stopwords-iso/stopwords-iso Shows that passing a non-iterable like `42` prints an error message and returns an empty set instead of raising. Also demonstrates pre-filtering with `has_lang` to avoid unknown codes. ```python # Error-handling pattern: invalid argument type is reported, not raised result = stopwords(42) # prints: 'langs' has to be string or iterable.' assert result == set() # Robust consumer pattern: pre-filter with has_lang requested = ["en", "zz", "de"] available = {c: stopwords(c) for c in requested if stopwords.has_lang(c)} ``` -------------------------------- ### has_lang(lang: str) -> bool Source: https://github.com/stopwords-iso/stopwords-iso Checks whether a given language code is supported by the stopwords dataset. Returns True if the language is available, False otherwise. ```APIDOC ## has_lang(lang: str) -> bool ### Description Checks whether a given language code is supported by the stopwords dataset. Returns True if the language is available, False otherwise. ### Parameters - **lang** (str) - Required - The ISO 639-1 language code to check. ### Returns - **bool** - True if the language is supported, False otherwise. ### Example ```python import stopwordsiso as stopwords stopwords.has_lang('en') # True stopwords.has_lang('xx') # False ``` ``` -------------------------------- ### stopwords-iso JSON data structure Source: https://github.com/stopwords-iso/stopwords-iso The module exports a single JSON object mapping ISO 639-1 language codes to arrays of stopwords. The object has 58 keys, each with a non-empty array of strings, and no duplicate entries within a language. The total is 21,707 stopwords across 58 languages. ```json { "af": ["'n", "aan", "af", "al", "as", ...], "ar": ["،", "آض", "آمينَ", "آه", "آهاً", ...], ... } ``` -------------------------------- ### langs() function signature Source: https://github.com/stopwords-iso/stopwords-iso Exact signature of the `langs()` function from `python/stopwordsiso/_core.py`. Returns a set of all supported ISO 639-1 language codes (58 codes). Never raises. ```python def langs() -> Set[str]: """Return set of support languages. ... """ return _LANGS ``` -------------------------------- ### stopwords(langs: Union[str, Iterable[str]]) -> Set[str] Source: https://github.com/stopwords-iso/stopwords-iso Returns the set of stopwords for the specified language(s). Accepts a single language code or an iterable of language codes. ```APIDOC ## stopwords(langs: Union[str, Iterable[str]]) -> Set[str] ### Description Returns the set of stopwords for the specified language(s). Accepts a single language code or an iterable of language codes. ### Parameters - **langs** (Union[str, Iterable[str]]) - Required - A single ISO 639-1 language code or an iterable of language codes. ### Returns - **Set[str]** - A set of stopwords for the requested language(s). ### Example ```python import stopwordsiso as stopwords stopwords.stopwords('en') # {'a', 'about', 'above', ...} stopwords.stopwords(['en', 'es']) # {'a', 'about', 'un', 'una', ...} ``` ``` -------------------------------- ### stopwords() function signature Source: https://github.com/stopwords-iso/stopwords-iso Exact signature of the `stopwords()` function from `python/stopwordsiso/_core.py`. Accepts a single language code or an iterable of codes, returns a set of stopwords. Never raises; invalid argument types are reported via print(). ```python def stopwords(langs: Union[str, Iterable[str]]) -> Set[str]: """Get a set of stopwords of all requested language. ... """ words = set() if langs: if type(langs) == str: if has_lang(langs): words.update(_STOPWORDS_ALL[langs]) else: try: iter(langs) # test if langs is iterable for lang in langs: if has_lang(lang): words.update(_STOPWORDS_ALL[lang]) except TypeError: print("'langs' has to be string or iterable.'") return words ``` -------------------------------- ### Stopwords data JSON format Source: https://github.com/stopwords-iso/stopwords-iso/blob/master/python/README.md The stopwords collection is stored in JSON format with language codes as keys and lists of stopwords as values. ```json { "af": [ "aan", "af", "al", "as", ], "ar": [ "آض", "آمينَ", "آه", "آهاً", ], } ``` -------------------------------- ### has_lang function definition Source: https://github.com/stopwords-iso/stopwords-iso Checks if stopwords exist for a given ISO 639-1 language code. Returns True if the language is in the _LANGS set, False otherwise; never raises. ```python def has_lang(lang: str) -> bool: """Check if has stopwords for a language. ... """ return lang in _LANGS ```