Stopwords¶
kenon.stopwords.get_stopwords(lang='english', extra=None, sources=None)
¶
Return a merged, frozen set of stopwords.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lang
|
str
|
Language name as used by NLTK (e.g. |
'english'
|
extra
|
list[str] | None
|
Additional tokens to add. |
None
|
sources
|
list[str] | None
|
Which source lists to include. Supported: |
None
|
Returns:
| Type | Description |
|---|---|
frozenset[str]
|
A frozenset of lowercase stopword strings. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
ValueError
|
If an unsupported source name is given. |
Contract
- The returned frozenset contains only lowercase strings.
extrawords are always present in the result.- NLTK data is auto-downloaded if missing.
Examples:
>>> sw = get_stopwords("english")
>>> "the" in sw
True
>>> sw2 = get_stopwords("english", extra=["gonna", "wanna"])
>>> "gonna" in sw2
True