Repository navigation
fix(email): don't take an opening "Thanks for ..." line for the sign-off - #111
ahmedembeddedxx wants to merge 1 commit into
Conversation
|
Thank you, deleting the request after a "Thanks for ..." opener is a nasty failure for support mail. Today's |
The sign-off pattern accepted any short line that started with a closing
word, followed by anything made of word characters, spaces and ",!.".
So an opener like "Thanks for getting back to me." or "Best time to reach
me is after 5pm." was taken for the signature, and everything below it
(the actual request) was cut. For emails of nine lines or fewer the
search starts at line 1, so the most common reply opener in support mail
reduced the body to "Hi,". The bare "best" prefix also matched words like
"Bestellung" ("order" in German).
A sign-off line now has to be a closing phrase, optionally followed by up
to three capitalised name tokens ("Thanks, Alice", "Best regards, Dr.
Jane Doe"). A closing written as a sentence ("Thanks for your help,") is
no longer stripped and stays in the body. Where the two goals conflict,
the cleaner keeps text, as in NandhaKishorM#94.
722d384 to
6c00f25
Compare
|
Rebased onto One thing worth flagging from the merge: #200 added the Portuguese/Spanish sign-offs with the rule that they "match only on their own ... unlike the English marker no trailing words are allowed". This PR is that same rule for English, so both markers now behave the same way. In Re-ran everything after the rebase: |
|
#132 landed the same fix, so I'm closing this in favour of it — same rule (closing word, optional continuation, at most a name), and it reaches every opener case this branch had: all 7 of mine are kept on Two things from my suite that #132 does not reach, so they are not lost: Thanks for the review, and no objection to the outcome — the bug is fixed either way. |
|
Thank you for rebasing, and for pointing out that the English sign-off rule should behave like the Portuguese and Spanish one from #200. #132 landed first and fixes the same bug with a single |
clean_email_bodytreats any short line that starts with a closing word as the sign-off and cuts everything below it. The most common opener in a support reply is exactly such a line, so the request is deleted and only the greeting survives:Agent.predict/Router.predictthen classifies an email it can no longer see, and nothing warns.Routing reads the same body, so the email can also go to the wrong checkpoint:
Cause
laya/email.py, in_SIGNATURE_MARKERS:After the keyword,
[\w ,!.]*accepts any run of words, so a whole sentence qualifies as long as it fits in the 40-character limit.best,kindandwarmon their own also match ordinary words and prefixes ("Best time to…", "Kind of urgent…", "Bestellung…"). For emails of nine lines or fewer the search starts at line 1, so the second line of a short email is always a candidate.Change
A sign-off line now has to be a closing phrase (the same set as before, except that
kindandwarmneedregardsorwishesafter them). The sender's name may follow, as up to three capitalised tokens: "Thanks, Alice", "Best regards, Dr. Jane Doe", "Regards, Łukasz"._CLOSINGmatches the phrase. The name check lives in_is_sign_offso it can usestr.isupper()and accept non-ASCII names. The--and "Sent from my…" markers are unchanged, and so is the search window.Before / after
Thanks for getting back to me.+ request'Hi,'Thank you for your reply.+ request'Hello,'Best way to reach me is by phone.+ request'Hi support,'Cheers for the quick fix yesterday.+ request'Hey,'Thanks, I tried that already.+ request'Hi,'Bestellung 4471 ist nicht angekommen.+ request'Hallo,'Thanks,/Best regards,/Thanks again!/Best regards, Dr. Jane Doe/Regards, ŁukaszTrade-off
A closing written as a sentence (
Thanks for your help,,Thank you for your time.) with a name after it used to be stripped. Now it stays, so the body ends with that line and the name. I couldn't find a rule that separates it from an opener likeThanks for getting back to me.without cutting real requests again. Like #94, this errs towards keeping text: an extra pleasantry does no harm, but a missing request does.Verification
tests/test_email.pygains 8 opener cases and 22 sign-off cases, for 41 in total.main(573e5b6): 33 passed, 8 failed. All 8 failures are opener cases. Every sign-off case already passes onmain, so real closings are cut exactly as before.test_router,test_criteria,test_download,test_shortlist,test_decision_model,test_packaging), as do the CI ruff check andcompileall. Tested on Python 3.11 with CPU-only torch.