liveBook · Manning

Indexing

As explained in Deep Learning with R, Third Edition

Indexing is the mapping of text tokens to integer positions in a vocabulary.

Indexing assigns each text token a unique integer ID, turning tokenized text into numeric data. A vocabulary provides the lookup set: matching each split token against it produces an integer index. section 14.6 section 14.2

vocabulary <- c("the", "quick", "brown", "fox", "jumped", "over", "dog", ".")
words <- split_words("The quick brown fox jumped over the lazy dog.")
indices <- match(words, vocabulary, nomatch = 0L)
indices

[1] 0 2 3 4 5 6 1 0 7 8

The example matches split words against a vocabulary; tokens without a match receive 0 in this call. section 14.2

How Deep Learning with R, Third Edition covers it

How deep it goes
Defines indexing and demonstrates vocabulary matching, without detailing model internals.
Examples
Uses a sentence, a word vocabulary, and R matching to show tokens mapped to integer positions.
What it assumes
Assumes text has been split into tokens and a vocabulary is available for lookup.
What you can do after
Apply R's match() to map split tokens to vocabulary indices, with unmatched tokens returning 0 in the example.
How it connects
Connects indexing to tokenization, standardization, splitting, and character, word, and subword tokenization.

Also explained in

Compare how 15 books explain indexing →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Deep Learning with R, Third Edition. The section links point to the parts of the book it draws on.