Non-autoregressive System 1 decision engine. Typed choice, score and yes/no decisions over any text in a single forward pass, in 100+ languages, with a router that picks the right checkpoint per request.
Python calibrationclassificationdecision-modelhuggingfacejevmodernbertmultilingualnlppythonpytorchroutingtyped-decisionszero-shot
fix(email): the word "confidential" is not a disclaimer (#227)
PerryLink7599902dba4c
diff --git a/laya/email.py b/laya/email.pyindex cd8fa4dc..8770e184 100644--- a/laya/email.py+++ b/laya/email.py@@ -56,7 +56,14 @@ _DEVICE_FOOTER = re.compile(re.I,)_DISCLAIMER = re.compile(- r"(confidential|intended (solely )?for the (use of the )?(named )?(addressee|recipient)|"+ # English: tied to a disclaimer noun and a disclaimer tail, the way the Portuguese+ # branches below are. The bare word matched any sentence that merely mentioned it,+ # so "Is this confidential?" and "Confidential: I need a refund." were deleted whole.+ # `[^.]` rather than `[^.\n]`: a footer wraps, so "are\nconfidential" must still match.+ r"(\b(e-?mail|message|information|communication|transmission|contents?)\b[^.]{0,60}"+ r"\bconfidential\b[^.]{0,60}\b(intended|solely|addressee|recipient|privileged|"+ r"disclos|unauthori[sz]ed)|"+ r"\bconfidential\b[^.]{0,60}\b(and (may|is) (also )?privileged)|"r"if you (have )?received this (e-?mail|message) in error|"# Portuguese/Spanish: tied to "this message/e-mail" rather than the bare word `confidencial`,# which a sender's own request ("preciso do contrato confidencial") uses just as oftendiff --git a/tests/test_email.py b/tests/test_email.pyindex fdd6a261..266381c1 100644--- a/tests/test_email.py+++ b/tests/test_email.py@@ -287,6 +287,58 @@ for label, body in [check("pt/kept: " + label, clean_email_body(body), body)+# ------------------------------------------------- the word, without the disclaimer+# `confidential` was a bare substring of `_DISCLAIMER`, so any sentence that merely+# mentioned it was dropped. A one-sentence body that mentions it was deleted whole and+# the model was then scored on an empty state, silently. The Portuguese branches beside+# it were already tied to disclaimer phrasing for this reason; English now is too.+for label, body in [+ ("a question about the word", "Is this confidential?"),+ ("a policy question", "What is your confidentiality policy?"),+ ("a request containing the word", "Please keep this confidential but process my refund."),+ ("a request about handling", "Please treat this as confidential."),+ ("a question with a dash", "This is confidential - can you help?"),+ ("a question about an attachment", "Is the attached document confidential?"),+ ("a label prefix", "Confidential: I need a refund."),+ ("a question about information", "What is the information policy for contractors?"),+]:+ check("word only/kept: " + label, clean_email_body(body), body)+check_true(+ "word only/body is never emptied",+ clean_email_body("Is this confidential?").strip() != "",+)+check(+ "word only/email_state keeps the request",+ email_state("Question", "Is this confidential?")["body"],+ "Is this confidential?",+)++# ...while the real footers those branches exist for are still dropped+for label, body in [+ ("named addressee", "This email is confidential and intended solely for the named addressee."),+ ("the individual addressed",+ "This message is confidential and intended solely for the use of the individual to whom it is addressed."),+ ("may be privileged", "The information in this email is confidential and may be privileged."),+ ("wrapped across lines",+ "This email and any files transmitted with it are\n"+ "confidential and intended solely for the named addressee."),+]:+ check_true("word only/still dropped: " + label, not clean_email_body(body).strip())+check(+ "word only/request before a footer survives",+ clean_email_body("My account is locked.\n"+ "This email is confidential and intended solely for the named addressee.\n"+ "Please unlock it."),+ "My account is locked. Please unlock it.",+)+check(+ "word only/request inside one sentence survives",+ clean_email_body("Please unlock it. This email is confidential and intended solely "+ "for the named addressee."),+ "Please unlock it.",+)++print("\n%d passed, %d failed" % (len(PASS), len(FAIL)))for f in FAIL:print(" FAIL " + f)