Overview

Tokenization is the first step of almost every NLP pipeline. NLTK's sent_tokenize uses Punkt — an unsupervised ML model trained on abbreviation lists — to split sentences. word_tokenize then applies a regex with Penn Treebank conventions. Both are high-quality, widely used, and measurably slow.

The .NET replacement uses two Regex.Compiled patterns: one for sentence splitting on punctuation + capitalization heuristics, one for word extraction matching alphanumeric sequences. No trained model, no Python objects — just a tight state machine compiled to native code by the regex JIT.

Benchmark Setup

Three corpus sizes from a Wikipedia plain-text dump: