Tokenizing a Phrase for Search
A tokenizer divides text into units used by an index or query. Punctuation, case, and language affect the chosen units.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Trace a short title
A rule might turn “Files and I/O” into files, and, i, o. Another can retain I/O as a term. Those outputs provide different matches. Text splitting shows why boundaries matter.
Use a consistent query path
If indexing and querying use incompatible rules, the same visible phrase can produce different tokens. Test punctuation and non-ASCII examples. See Unicode text positions.[1]
Compare token boundaries with the user's expectation
A query rail-map can produce tokens rail and map if hyphen separates words. An exact identifier field may instead keep the entire value as one token. Apply compatible processing when indexing and querying the same field. See normalizing search terms.
General text policy: rail-map → rail, map
Exact identifier policy: rail-map → rail-map
Token positions should refer to the policy used by phrase search
Test punctuation, whitespace and scripts deliberately
A tokenizer suitable for one language or field may split another poorly. Record examples with apostrophes, punctuation and accents. Compare expected tokens before judging search results.