liveBook · Manning

Vocabulary

As explained in Data Without Labels

A vocabulary is the set of distinct words or tokens recognized in a corpus or text-processing system.

A vocabulary is the set of unique tokens found in a corpus. Tokenization produces those tokens, which may represent words, subwords, or characters. section 7.8

A vocabulary supports text preparation in several ways:

  • Collect unique tokens from the corpus after tokenization. section 7.8
  • Optionally apply upper and lower frequency thresholds to select tokens. section 7.9
  • Use the resulting vocabulary as the shared dimension for sentence vectors in a bag-of-words representation. section 7.9
  • Assign zero to vocabulary terms absent from a particular sentence. section 7.9

Two-sentence vocabulary

For “It is raining heavily” and “We should eat fruits,” the vocabulary contains every unique word from both sentences. Each sentence becomes a vector containing its word frequencies, with zeros for words it does not contain. section 7.9

Figure 7.6 We are assuming that in the vocabulary only two sentences are present and the first sentence will be represented as shown.
figure

Visualizes how a sentence is represented against a vocabulary containing the words from both example sentences. section 7.9

How Data Without Labels covers it

How deep it goes
Defines unique corpus tokens, frequency thresholds, and fixed-length vectors, but does not preserve word order or context.
Examples
Uses two short sentences to demonstrate vocabulary frequencies and zero-filled sentence vectors.
What it assumes
Assumes tokenization as the preceding step and teaches vocabulary construction from the resulting tokens.
What you can do after
Build it from scratch by extracting unique tokens and encoding sentences as vocabulary-sized frequency vectors.
How it connects
Links tokenization, one-hot encoding, bag of words, and document classification.

Also explained in

Compare how 13 books explain vocabulary →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Data Without Labels. The section links point to the parts of the book it draws on.