liveBook · Manning

Stop word

As explained in Natural Language Processing in Action, Second Edition

A stop word is a frequent function word that usually contributes relatively little substantive information to a phrase's meaning.

A stop word is a frequent function word—such as “a,” “the,” “and,” or “of”—that usually contributes little substantive information to a phrase’s meaning. Filtering these tokens can reduce NLP computation, but their relationships may still carry essential meaning. section 2.3.1

Choose stop-word handling for the application rather than applying a universal deletion rule:

  • Removing stop words can reduce the number of tokens an NLP pipeline must extract, store, and maintain. section 2.3.1
  • Retaining stop words can preserve relational information inside n-grams, even when the individual words appear uninformative. section 2.3.1
  • Deleting them can collapse distinct meanings: “reported to the CEO” and “reported as the CEO” both become “reported CEO.” section 2.3.1
  • Document-wide frequency statistics can provide an alternative to relying entirely on an arbitrary stop-word list. section 3.1

Preserving professional hierarchy

“Mark reported to the CEO” suggests that Mark reported upward, while “Suzanne reported as the CEO to the board” identifies Suzanne as the CEO. Keeping stop words preserves this distinction in four-grams; removing them erases it. section 2.3.1

Listing 2.2 A broad list of stop words
>>> import requests
>>> url = ("https://gitlab.com/tangibleai/nlpia/-/raw/master/"
...        "src/nlpia/data/stopword_lists.json")
>>> response = requests.get(url)
>>> stopwords = response.json()['exhaustive']            #1
>>> tokens = 'the words were just as I remembered them'.split()   #2
>>> tokens_without_stopwords = [x for x in tokens if x not in stopwords]
>>> print(tokens_without_stopwords)
['I', 'remembered']

A Python example loads an exhaustive stop-word list, filters a tokenized sentence, and leaves “I” and “remembered.” section 2.3.1

How Natural Language Processing in Action, Second Edition covers it

How deep it goes
Defines stop words, demonstrates filtering tradeoffs, and stops short of prescribing a universal list.
Examples
Uses stop-word lists, Python filtering, four-gram hierarchy examples, and common-token counts.
What it assumes
Assumes tokenization and n-gram formation while teaching stop-word behavior from basic examples.
What you can do after
Apply it via a tailored filter while checking whether removed words encode relationships or ambiguity.
How it connects
Connects stop words with tokenization, n-grams, bag-of-words vectors, term frequency, and inverse document frequency.

Also explained in

Compare how 4 books explain stop word →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Natural Language Processing in Action, Second Edition. The section links point to the parts of the book it draws on.