Skip to content

Split a Thai title glued to the start of the name off it (rules/W6) (#317) - #1324

Merged
derek73 merged 7 commits into
masterfrom
feat/issue-317-thai-front-peel
Nov 11, 2026
Merged

derek73 merged 7 commits into
masterfrom
feat/issue-317-thai-front-peel

Conversation

@derek73

@derek73 derek73 commented Nov 11, 2026 •

Copy link
Copy Markdown
Owner

Closes #317.

What changes

A listed title glued to the start of the name splits off and reads as the title (new rule W6, the glued-title peel). It mirrors W2's peel of honorifics glued to the end of a name.

text 3.0.1 / master this branch
นายสมชาย ใจดี given นายสมชาย title นาย, given สมชาย
นางสาวสุดา ใจดี given นางสาวสุดา title นางสาว, given สุดา
นาย สมชาย ใจดี given นาย, middle สมชาย title นาย, given สมชาย
ใจดี, นายสมชาย given นายสมชาย title นาย, given สมชาย
อาจารย์สรศักดิ์ ใจดี given อาจารย์สรศักดิ์ title อาจารย์, given สรศักดิ์
นายแพทย์สมชาย ใจดี given นายแพทย์สมชาย title นายแพทย์ (listed whole, not นาย + แพทย์)
นางสาวิตรี ใจดี given นางสาวิตรี title นาง, given สาวิตรี
อาจารย์ดร.สมชาย ใจดี given อาจารย์ดร.สมชาย title อาจารย์ดร., given สมชาย
นพพร ใจดี, นางาเซะ โทโมยะ given unchanged

How the peel decides:

  • Which words peel. A word peels only where the vocabulary marks it attached = { side = "before" }. That is the slot the build had reserved, rejecting it with "phase 1 (the Glued CJK honorifics are absorbed into the name (山田太郎様 → family 山田太郎様) #308 peel)". It compiles into a new private GLUED_TITLES set.
  • One peel, longest match first, falling back to a shorter title where the longest would leave a Thai vowel or a mark (นางสาวิตรี → นาง + สาวิตรี). A hyphen, a digit or the repetition mark after a title blocks the peel (นางสาว-สุดา stays whole). It never cuts a title that is listed whole, and never a title that may be a given name, a caller's included.
  • What's left must open the way a Thai word can. That keeps Japanese names written in Thai letters whole (นางิ Nagi, นางาเซะ Nagase).
  • Where it looks. The first word of the name, and the first word of the given part after a family comma, stepping past titles written apart (including dotted pairs like รศ.ดร., though never a word holding a name, such as ดร.สมชาย). Under a family-first order, or before a family comma, that first word is the surname. Surnames were vetted too: 1 of 12,073 Thai surnames opens with นาย, none with the others.
  • A remainder still glued at a full stop (อาจารย์ดร.สมชาย) divides as T8 divides it written apart.

Vocabulary. th.toml lists the salutations นาย, นาง, นางสาว and the feminine rank ว่าที่ร้อยตรีหญิง, and marks them and #1166's spelled-out titles to peel. The short forms (นพ, ดร, ศ, พญ, ทพ) and คุณ are not marked, because each opens real given names.

How the words were vetted

Source What it showed
12,880 distinct Thai given names: PyThaiNLP's name lists (Apache-2.0) and the 2019 election candidates in ELECT's dataset No given name opens with นาง, นางสาว or any spelled-out title. One opens with นาย (นายณัฐ in the female list: the salutation typed in). นพ opens 33, คุณ 12.
Thai Wikipedia's people index (46,211 names) Names opening with นาย or นาง are the honorific (นางวิสาขา) or a noble rank (นายจำนงราชกิจ), or Japanese names, which the opening-letter guard keeps whole.
How people write it (ORCID's Thai given-name boxes) นาย glued 23 times vs written apart 2, นางสาว 8 vs 2, นาง 4. The 2019 candidates (title in its own box): นาย 10,059, นางสาว 1,676, นาง 1,428.

The source lists aren't committed. They're cited in decisions/W6.

Measured

Against master ed7dfb8:

  • orcid-researchers: 7 names move, and each one gains its title and keeps the given name. All 7 count as field-agreement "regressions" only because the filer typed the salutation into the given-name box.
  • jrc-names: reads exactly as master. No other local corpus holds Thai names, and only a word opening with a glued title can move.
  • Committed snapshot: no corpus name moves. It gains W6's examples.
  • Frames: a name with no word opening with a glued title pays none. I caught a generator in the gate costing 2–3 per non-ASCII name and replaced it with a loop. The reference row is unchanged at 344.

Review rounds

The code review and the docs review found these, and each is fixed with a test row that fails on the first commit:

  • A given name lost to the title. The remainder glued at a full stop wasn't divided, so อาจารย์ดร.สมชาย lost its given name to the title.
  • No fallback to a shorter title. Without it, นางสาวิตรี stayed whole.
  • A dotted title pair wasn't stepped past.
  • A caller's word could be split with no title read. A title that is also a given name, once marked attached, cut the word and read no title.
  • Lexicon.add accepted a multi-word attached title, which the build refuses.

A third review, of the fix commits, found two places where those fixes over-reached: the site walk skipped a title glued to a name (นางรศ.ดร.สมชาย kept the whole word as the title), and the fallback fired behind a hyphen (นางสาว-สุดา → นาง + สาว-สุดา). Both are fixed, with rows that fail on the previous commit. The Codecov failures were three uncovered lines: two build refusals, which now have mutation rows, and a dead check, which is removed.

The W6 and decisions text was tightened to match the code: Then says "marked to peel", and the Except is about a title listed whole.

Accepted costs:

Open, recorded in decisions/W6

Tests

  • tests/v2/cases.py: eight rows covering the four comma shapes (no comma, a name before the comma, one word before it, nothing before it), the listed-whole word, and the short-form and Japanese boundaries.
  • tests/v2/test_lexicon.py: the off switch (attached=None), a caller's attached="before", and a check that every shipped glued title actually peels.
  • tests/v2/test_vocab.py: build mutations for the wrong side and for a multi-word title, and the README's property table probed for both categories.
  • Rules and decisions: rules/W6, decisions/W6, both indexes, the vocab README, the Lexicon.add docstring, AGENTS.md's set list, and the release log.

🤖 Generated with Claude Code

…317)

A listed title written `attached = { side = "before" }` glued to the
start of the name's first word, or the given part's after a family
comma, splits off once, longest first, and reads as the title:
นายสมชาย ใจดี -> title 'นาย', given 'สมชาย' (1.4.0 through 3.0.1: given
'นายสมชาย'). A word listed whole keeps its reading (นายแพทย์), and
nothing peels where what is left opens with a Thai vowel written after
its consonant (นางิ, นางาเซะ, Japanese names in Thai letters).

th.toml lists the salutations นาย, นาง, นางสาว and ว่าที่ร้อยตรีหญิง, and
marks them and #1166's spelled-out titles attached; the short forms
(นพ, ดร, ศ, พญ) and คุณ are not, each opening real given names. Vetted
against 12,880 Thai given names (PyThaiNLP, the 2019 election
candidates) and Thai Wikipedia's people index.

The title side compiles into GLUED_TITLES (Lexicon._sets.glued_titles);
the build and Lexicon.add take side "before" on a one-word title. The
peel runs in script_segment before W2's, behind a C-level prefix test
that costs a name with no glued title no frame. ORCID moves 7 Thai
names, each gaining its title; jrc-names none.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@derek73 derek73 added this to the 3.1 milestone Nov 11, 2026
@derek73 derek73 added enhancement vocabulary Fixed by a word-list entry: per-word vocabulary and language packs titles Titles and honorifics (rules/H) non-latin-script Names written in a script other than Latin (rules/W) tokens Tokens, separators and punctuation (rules/T) labels Nov 11, 2026
@derek73 derek73 self-assigned this Nov 11, 2026
derek73 and others added 6 commits November 10, 2026 21:11
Divide a remainder still glued at a full stop as T8 would (อาจารย์ดร.สมชาย
lost its given name to S3's any-title-chunk reading); leave a title that
may be a given name out of GLUED_TITLES, a caller's included, which cut
the word without reading a title; refuse attached='before' on a phrase
in Lexicon.add as the build does. rules/W6 states the reach before the
comma and under family-first orders, surnames vetted (1 of 12,073 opens
with นาย); one peel is a stated boundary. Comments moved to the peel
they describe.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fall back to a shorter marked title where the longest leaves no word
(นางสาวิตรี -> นาง + สาวิตรี, as written apart); pass over a title
joined at its full stops in front of the site (รศ.ดร. นายแพทย์สมชาย).
rules/W6's Then says marked, its Except says a title listed whole, the
opening guard moves into the longest-first bullet with boundary rows,
and decisions/W6 records the review, the spaced move and the caller's
listed name the guard does not read.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The site walk passed over any word holding a title chunk, a title
glued to a name included (นางรศ.ดร.สมชาย kept the word as the title;
อาจารย์รศ.ดร.สมชาย นายใจดี peeled the second word): it now passes over
only a word every chunk of which is a listed title. The fallback to a
shorter title fired behind a hyphen, a digit or the repetition mark
(นางสาว-สุดา -> นาง + สาว-สุดา): it now fires only behind a Thai vowel
written after its consonant or a mark, anything else peeling nothing.
A dead title check in the peel goes; the build's two attached refusals
on a title and the lowercase-length guard get rows (codecov).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@derek73
derek73 merged commit 7ebd855 into master Nov 11, 2026
14 checks passed
@derek73
derek73 deleted the feat/issue-317-thai-front-peel branch November 11, 2026 05:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement non-latin-script Names written in a script other than Latin (rules/W) titles Titles and honorifics (rules/H) tokens Tokens, separators and punctuation (rules/T) vocabulary Fixed by a word-list entry: per-word vocabulary and language packs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Thai honorifics are glued to the given name (นายสมชาย → given "นายสมชาย")

1 participant