OCT 18, 2026·1 MIN READ
A tokenizer gotcha that cost me an afternoon
Why my Tagalog word counts were wildly off, and the one-line fix.
- nlp
- til
Short one. My word counts for Tagalog text were about 30% too high, and it took way too long to see why.
CAUTION
Subword tokenizers split words like pinakamaganda into several pieces. Counting tokens is not the same as counting words.
PYTHON
# wrong: counts subword tokens
len(tokenizer.tokenize(text))
# right: count words first
len(text.split())Obvious in hindsight. Most bugs are.