How asubah/minitok-template works
minitok is a course-project tokenizer: users provide a JSON token specification and source text, which the CLI turns into tokens using regex-compiled finite automata and maximal-munch scanning. The README also documents a separate BPE comparison exercise and a scratch-BPE bonus. Source excerpts show CLI dispatch and the automata/regex interfaces; connections between compiler stages are included where the README explicitly describes them. The comparison exercise has no implementation file in the supplied tree.
Main entry points: __main__.py Tokenize CLI · automata.py Combined token DFA · regex_compiler.py Thompson compiler · bpe_from_scratch.py Scratch BPE
Components 12
Token specification
- Spec loader
minitok/spec.py
Automata compilation
- Regex parser
minitok/regex_compiler.py - Thompson compiler
minitok/regex_compiler.py - NFA model
minitok/automata.py - Subset construction
minitok/automata.py - Combined token DFA
minitok/automata.py
Tokenization runtime
- Maximal-munch scanner
minitok/automata.py - Tokenize CLI
minitok/__main__.py - Scratch BPE
minitok/bpe_from_scratch.py
LLM comparison
- tiktoken
- Tokenizer comparison
Other components
- Project user
Connections 15
- Project user → Tokenize CLI: runs
README.md - Tokenize CLI → Spec loader: loads spec
minitok/__main__.py - Tokenize CLI → Combined token DFA: builds DFA
minitok/__main__.py - Tokenize CLI → Maximal-munch scanner: scans text
minitok/__main__.py - Regex parser → Thompson compiler: parses for
minitok/regex_compiler.py - Thompson compiler → NFA model: compiles to
README.md - Combined token DFA → Thompson compiler: compiles patterns
README.md - Combined token DFA → Subset construction: determinizes
README.md - Subset construction → NFA model: reads NFA
minitok/automata.py - Maximal-munch scanner → Combined token DFA: uses DFA
README.md - Project user → Scratch BPE: trains or encodes
README.md - Project user → Tokenizer comparison: compares tokenizers
README.md - Tokenizer comparison → tiktoken: uses encoding
README.md - Tokenizer comparison → Maximal-munch scanner: compares output
README.md - Tokenizer comparison → Scratch BPE: compares output
README.md