---
title: "tokenization"
type: concept
related: [Morpheme, Tokenization, Bpe, Corpus]
source: https://www.jemoka.com/posts/kbhtokenization/
confidence: high
status: active
---

Every NLP task involve some kind of text normalization.
tokenizing words normalizing word formats (lemmatize?) sentence and paragraph segmentation For Latin, Arabic, Cyrillic, Greek systems, spaces can usually be used for tokenization. Other writing systems can&rsquo;t do this. See morpheme
Subword Tokenization Algorithms for breaking up tokens using corpus statistics which acts on lower-than-word level.
BPE Unigram Language Modeling tokenization WordPiece They all work in 2 parst:
a token learner: takes training corpus and derives a vocabulary set a token segmenter that tokenizes text according to the vocab See also Downsides of Subword Tokenization
tr For those languages, you can use these systems to perform tokenization.
tr -sc &#34;A-Za-z&#34; &#34;\n&#34; &lt; input.txt this takes every form which is not text (-c is the complement operator) and replaces it with a newline. -s squeezes the text so that there are not multiple newlines.
This turns the text into one word per line.
Sorting it (because uniq requires it) and piping into uniq gives word count
tr -sc &#34;A-Za-z&#34; &#34;\n&#34; &lt; input.txt | sort | uniq We can then do a reverse numerical sort:
tr -sc &#34;A-Za-z&#34; &#34;\n&#34; &lt; input.txt | sort | uniq | sort -r -n which gives a list of words per frequency.
This is a BAD RESULT most of the time: some words have punctuation with meaning that&rsquo;s not tokenizaiton: m.p.h., or AT&amp;T, or John's, or 1/1/12.
What to Tokenize &ldquo;I do uh main- mainly business data processing&rdquo;
uh: filled pause main-: fragments Consider:
&ldquo;Seuss&rsquo;s cat in the cat is different from other cats!&rdquo;
cat and cats: same lemma (i.e. stem + part of speech + word sense) cat and cats: different wordforms We usually consider a token as distinct wordform, counting duplicates; whereas, we usually consider word types as unique, non-duplicated distinct wordforms.
clitics John's: word that doesn&rsquo;t stand on its own.
