Repository navigation
fix(email): closings the case rule does not reach - #245
Merged
NandhaKishorM merged 2 commits intoSep 23, 2026
Merged
NandhaKishorM merged 2 commits into
NandhaKishorM merged 2 commits into
Conversation
NandhaKishorM#132 replaced the trailing-words pattern with a closing word, an optional continuation and a capitalised name, which is the right rule. Three closings fall outside it and are no longer cut, though the pattern before NandhaKishorM#132 cut them: `Warmest regards,` (`warmest` is not in the alternation), `Thanks and regards,` and `Thanks & Regards,` (not among the continuations), and `Regards, Łukasz` (`[A-Z]` is ASCII, so a name in any other script reads as a sentence). Add the two closings, and match the name by excluding the lowercase letters rather than listing the uppercase ones, so the case signal NandhaKishorM#132 introduced holds outside ASCII. A sentence that merely starts the same way ("Thanks and the team will confirm it today.") is still kept.
Owner
|
Thank you, this is exactly the follow-up I hoped for on #111: one rule, extended, instead of two. Adding |
baninaveen
pushed a commit
to baninaveen/laya
that referenced
this pull request
Sep 24, 2026
NandhaKishorM#132 replaced the trailing-words pattern with a closing word, an optional continuation and a capitalised name, which is the right rule. Three closings fall outside it and are no longer cut, though the pattern before NandhaKishorM#132 cut them: `Warmest regards,` (`warmest` is not in the alternation), `Thanks and regards,` and `Thanks & Regards,` (not among the continuations), and `Regards, Łukasz` (`[A-Z]` is ASCII, so a name in any other script reads as a sentence). Add the two closings, and match the name by excluding the lowercase letters rather than listing the uppercase ones, so the case signal NandhaKishorM#132 introduced holds outside ASCII. A sentence that merely starts the same way ("Thanks and the team will confirm it today.") is still kept. Co-authored-by: NandhaKishorM <nandakishor@convaiinnovations.com>
NandhaKishorM
pushed a commit
that referenced
this pull request
Sep 27, 2026
`[^\W\d_a-zß-öø-ÿ]` excludes the lowercase letters only where Latin-1 spells them, so a
name starting with ł, ż, д or α counted as capitalised-in-any-script, the line was cut as
a sign-off, and whatever followed it went with the cut:
$ python -c "from laya.email import clean_email_body as c; print(c('Hi,\n\nPlease refund invoice 4411.\nThanks, żaneta\nCould you confirm by Friday?'))"
Hi,
Please refund invoice 4411.
The TS port asks the case question per character instead (`[\p{Lu}\p{Lt}\p{Lo}]`), which is
the rule #245's comment describes — "a name is capitalised in any script" — so Python moves
to it: the tail is matched structurally, and each token's first character is judged by
Unicode category (Lu/Lt/Lo). A combining mark rides along with the letter before it
(`Jose\u0301` spells `José`), which `\w` alone does not cover.
$ python tests/test_email.py # before the fix, with the new cases
105 passed, 5 failed
$ python tests/test_email.py # after
110 passed, 0 failed
Deliberate choices tested:
- **Categories, not a predicate.** `token[0].isalpha() and not token[0].islower()` accepts
modifier letters (`Thanks, ʻŌlelo`), which the port rejects; the category check agrees
with the port on the whole 58-case corpus, the predicate does not.
- **A callable marker, not a wider class.** `re` cannot say "not a lowercase letter in any
script"; listing ranges is what failed. The English sign-off joins `_SIGNATURE_MARKERS` as
a callable (the port's list is callables too), and `_marker_matches` dispatches it.
- **Marks via `\u0300-\u036f`.** The combining diacriticals are the block a decomposed
Latin-script name actually carries; other mark blocks are not covered, matching `\w`.
Known limitation: a mark from another block (a Devanagari matra, say) still ends the token
in Python where the port's `\p{M}` carries it. The port needs no code change, only its
comment, which quoted the old class. Related: #422 touches other hunks of
`laya-ts/src/email.ts`; no line overlap.
ian-p-johnson
added a commit
to ian-p-johnson/rusty_laya
that referenced
this pull request
Sep 28, 2026
Diff census: sequence/checkpoint/probe (EN+MM) bit-identical, presets identical, detection gains 3 keys with 0 shared-value changes, email 1/8 (signature no longer stripped, upstream NandhaKishorM#245), answers: per-answer answer_confidence added + choice_30 temperature clamp [0.5,5] (logits identical, so the exported ONNX graphs stay valid). Gate state 46 passed / 2 failed: parity_answers (clamp + answer_confidence) and email parity (closing rule) -- the cycle-2 worklist. Ring-3 e2e green.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #132, which replaced the
[\w ,!.]*tail with a closing word, an optional continuation and a capitalised name. That rule is right, and this keeps it; three closings just fall outside it and are no longer cut, though the pattern before #132 cut them:mainWarmest regards,Thanks and regards,Thanks & Regards,Regards, Łukaszwarmestis not in the alternation,and/& regardsis not one of the continuations, and[A-Z]is ASCII, so a name in any other script reads as a sentence. Each one leaves the signature block in the body that the sign-off rule exists to remove.Change: add the two closings, and match the name by excluding the lowercase letters rather than listing the uppercase ones, so the case signal from #132 holds outside ASCII.
Trade-off: the name class now also admits a lowercase letter in a script that has no case (
Regards, мойwould match). It costs a line that already begins with an English closing and stays under the 40-character guard, which the previous pattern cut anyway.Verification: 86/86 in
tests/test_email.py, including the 11 positive controls and the 4 body-line cases from #132. Reverting onlylaya/email.pytomainfails the 6 new cut cases. Guards for the wider closing are in the suite too ("Thanks and the team will confirm it today." is kept). The 16 suites CI runs, ruff andcompileallpass on 3.10, 3.11, 3.12 and 3.13.