Skip to content

fix(email): closings the case rule does not reach - #245

Merged
NandhaKishorM merged 2 commits into
NandhaKishorM:mainfrom
ahmedembeddedxx:fix/email-signoff-coverage
Sep 23, 2026
Merged

NandhaKishorM merged 2 commits into
NandhaKishorM:mainfrom
ahmedembeddedxx:fix/email-signoff-coverage

Conversation

@ahmedembeddedxx

Copy link
Copy Markdown
Contributor

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:

line before #132 on main here
Warmest regards, cut kept cut
Thanks and regards, cut kept cut
Thanks & Regards, kept kept cut
Regards, Łukasz cut kept cut

warmest is not in the alternation, and/& regards is 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 only laya/email.py to main fails 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 and compileall pass on 3.10, 3.11, 3.12 and 3.13.

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.
@NandhaKishorM

Copy link
Copy Markdown
Owner

Thank you, this is exactly the follow-up I hoped for on #111: one rule, extended, instead of two. Adding warmest and the and/& regards continuation, and matching the name by excluding lowercase letters rather than listing ASCII capitals, covers Regards, Łukasz while keeping #132's case signal. Your table makes the before/after easy to check, and all email tests pass. Merging, and I'll close #111 in favour of this.

@NandhaKishorM
NandhaKishorM merged commit 4f2aaf3 into NandhaKishorM:main Sep 23, 2026
14 checks passed
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.
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.

2 participants