Skip to content

Add source-preserving tokenizer - #9

Merged
aryamantodkar merged 1 commit into
mainfrom
codex/add-tokenizer
Aug 22, 2026
Merged

Add source-preserving tokenizer#9
aryamantodkar merged 1 commit into
mainfrom
codex/add-tokenizer

Conversation

@aryamantodkar

Copy link
Copy Markdown
Contributor

Summary

  • add a deterministic Unicode-aware tokenize() interface
  • return immutable WordToken values with original [start, end) character offsets
  • preserve original casing and internal straight or curly apostrophes
  • separate punctuation while ignoring whitespace as tokens
  • cover common ASR, numeric, email-like, hyphenated, and time-like inputs

Why

The contextual classifier needs word-level inputs, while every public span and later edit must continue to refer to exact coordinates in the original transcript. This tokenizer establishes that source-preserving seam before model subword tokenization is introduced.

Invariant

For every returned token, text[token.start:token.end] == token.text. Empty and whitespace-only inputs return no tokens.

Without this invariant, model predictions could be mapped back to the wrong transcript evidence, breaking provenance and potentially rewriting text outside the accepted span. The tests independently pin exact tokens and offsets across whitespace, punctuation, apostrophes, leading zeros, alphanumeric values, email-like text, hyphens, and time punctuation.

Validation

  • uv run pytest — 44 passed
  • uv run ruff check .
  • uv build
  • git diff --check

@aryamantodkar
aryamantodkar merged commit dd0b906 into main Aug 22, 2026
@aryamantodkar
aryamantodkar deleted the codex/add-tokenizer branch August 22, 2026 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant