liveBook · Manning

Standard

As explained in Deep Learning with R, Third Edition

Standardization is the normalization of text through transformations such as case conversion, punctuation removal, or encoding normalization.

Standardization normalizes text before tokenization so irrelevant encoding differences do not create separate representations. Common transformations include lowercasing, punctuation removal, and accent normalization. section 14.2 section 14.6

Making equivalent text more similar

“Sunset came. I stared at the México sky. Isn’t nature splendid?” becomes “sunset came i stared at the méxico sky isnt nature splendid” after lowercasing and punctuation removal. Removing accent marks would make “México” and “Mexico” match as well. section 14.2

A tokenizer applies standardization as the first part of a simple preprocessing pipeline:

  • Standardize the input, such as by converting characters to lowercase. section 14.2.1
  • Split the standardized text into characters or words. section 14.2.1
  • Index tokens against a vocabulary, assigning unknown terms a special index. section 14.2
Listing 14.1 A basic character-level tokenizer
new_char_tokenizer <- function(vocabulary, nomatch = "[UNK]") {
  self <- new.env(parent = emptyenv())
  attr(self, "class") <- "CharTokenizer"

  self$vocabulary <- vocabulary
  self$nomatch <- nomatch

  self$standardize <- function(strings) {
    str_to_lower(strings)
  }

  self$split <- function(strings) {
    split_chars(strings)
  }

  self$index <- function(tokens) {
    match(tokens, self$vocabulary, nomatch = 0L)
  }

  self$tokenize <- function(strings) {  #1
    strings |>
      self$standardize() |>
      self$split() |>
      self$index()
  }

  self$detokenize <- function(indices) { #2
    indices[indices == 0] <- NA
    matches <- self$vocabulary[indices]
    matches[is.na(matches)] <- self$nomatch
    matches
  }

  self
}

Inspect a complete character-level tokenizer that lowercases input before splitting and indexing it. section 14.2.1

How Deep Learning with R, Third Edition covers it

How deep it goes
Explains motivation, transformations, and tokenizer placement, but defers broader normalization strategies and detailed encoding internals.
Examples
Demonstrates lowercase conversion, punctuation removal, accent handling, Moby Dick tokenizers, vocabularies, and unknown-token replacement.
What it assumes
Assumes basic text preprocessing, while defining standardization within the broader tokenization pipeline.
What you can do after
Apply it via a character- or word-level tokenizer before vocabulary lookup and integer indexing.
How it connects
Connects standardization to tokenization, splitting, indexing, vocabulary, feature engineering, and character, word, or subword tokenization.

Also explained in

Compare how 6 books explain standard →

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.