From 9ec066b7f94f5af93a47069294d048542f05df86 Mon Sep 17 00:00:00 2001 From: mohanenm <20827960+mohanenm@users.noreply.github.com> Date: Thu, 26 Nov 2026 02:30:50 -0500 Subject: [PATCH 1/3] Wrap a long line in the security doc --- docs/security.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/security.md b/docs/security.md index 2b48b34..ceb2d01 100644 --- a/docs/security.md +++ b/docs/security.md @@ -44,9 +44,10 @@ Every other command installs a network guard (see below) before doing any work. ### R2. Careless logging and error output - No raw text in logs, exceptions, tracebacks or debug output. Errors carry a code, a position (field, turn, line, offset) and a category, never content. -- The CLI catches every exception at the top level. For offrecord's own errors it prints the code and - position. For unexpected exceptions it prints only the exception *type* and the code location, - never the exception message (third-party messages, e.g. decode errors, can embed input bytes). +- The CLI catches every exception at the top level. For offrecord's own errors it prints the + code and position. For unexpected exceptions it prints only the exception *type* and the code + location, never the exception message (third-party messages, e.g. decode errors, can embed + input bytes). - `--debug` prints stack frames (file, line, function) but never exception messages or locals. - `sys.excepthook`, `threading.excepthook`, `sys.unraisablehook` and `warnings.showwarning` are replaced with content-free versions; logging's last-resort handler is removed and the From 05b0c78b644cc3fe1ea3451de20d64601c407cf4 Mon Sep 17 00:00:00 2001 From: mohanenm <20827960+mohanenm@users.noreply.github.com> Date: Thu, 26 Nov 2026 02:30:50 -0500 Subject: [PATCH 2/3] Catch spoken URLs with paths after 'at', split names and newer endings "find it online at acme dot test slash help" was read as an email, which cannot have a path, so the path stayed visible. A domain followed by a path is now a URL. Also join path words with dash, join a domain name spoken as two words, and accept newer endings such as .health after a literal "dot". URL recall on tuning-hw, validation and the user set goes to 100%. --- src/offrecord/normalize/spoken.py | 46 ++++++++++++++++++++-- src/offrecord/redact/detectors/patterns.py | 5 ++- tests/test_redact.py | 20 ++++++++++ 3 files changed, 66 insertions(+), 5 deletions(-) diff --git a/src/offrecord/normalize/spoken.py b/src/offrecord/normalize/spoken.py index b6a57f0..5075371 100644 --- a/src/offrecord/normalize/spoken.py +++ b/src/offrecord/normalize/spoken.py @@ -457,11 +457,25 @@ def digit_runs(text: str) -> list[Edit]: "eu", "tv", "xyz", "cloud", "tech", "example", "test", "invalid", "local", "internal", "ie", "nz", "sg", "za", "br", "mx", "pl", "be", "at", "dk", "fi", "pt", "gr", "kr", "cn", } # fmt: skip +# Newer endings that are also ordinary words: only after a literal "dot" ("acme dot health"), +# never "point" or "period" ("at this point today"). +WORD_TLDS = { + "health", "care", "clinic", "dental", "law", "legal", "insurance", "bank", "finance", + "shop", "store", "online", "site", "agency", "studio", "solutions", "services", "network", + "digital", "media", "systems", "group", "academy", "school", "events", "travel", "energy", + "realty", "properties", +} # fmt: skip _DOT = {"dot", "period", ".", "point"} _AT = {"at", "@"} _LOCAL_JOIN = {"dot": ".", "period": ".", ".": ".", "underscore": "_", "_": "_", "dash": "-", "hyphen": "-", "-": "-"} # fmt: skip _STOP_LOCAL = {"me", "us", "him", "her", "them", "is", "it's", "email", "mail", "address"} +# Words that never join a domain label spoken as two words ("acme health dot org"). +_NOT_LABEL = { + "site", "website", "page", "link", "url", "visit", "go", "at", "to", "is", "on", "our", + "the", "their", "your", "my", "new", "web", "online", "check", "email", +} # fmt: skip +_PATH_JOIN = {"dash": "-", "hyphen": "-", "underscore": "_", "-": "-", "_": "_"} _DOMAIN_TOKEN_RE = re.compile(r"[^\W_]+(?:-[^\W_]+)*(?:'s)?|[^\w\s]|_") @@ -484,7 +498,9 @@ def spoken_email_url(text: str) -> list[Edit]: used_until = -1 for k, t in enumerate(toks): tld = _strip_possessive(t.low) - if k <= used_until or tld not in TLDS or k < 2 or toks[k - 1].low not in _DOT: + if k <= used_until or k < 2 or toks[k - 1].low not in _DOT: + continue + if tld not in TLDS and not (tld in WORD_TLDS and toks[k - 1].low == "dot"): continue # Only rewrite if at least one separator is spoken (otherwise it is already literal). # Walk back over "label dot label dot tld". @@ -492,15 +508,29 @@ def spoken_email_url(text: str) -> list[Edit]: domain = [_strip_possessive(t.text)] spoken = toks[k - 1].low != "." while j - 2 >= 0 and toks[j - 1].low in _DOT and _is_label(toks[j - 2]) and len(domain) < 6: - domain.insert(0, toks[j - 2].text) + label = toks[j - 2].text spoken = spoken or toks[j - 1].low != "." j -= 2 + # Speech-to-text often splits a name: "acme health dot org" -> acmehealth.org. + if ( + spoken + and j - 1 >= 0 + and _is_label(toks[j - 1]) + and toks[j - 1].low not in _NOT_LABEL + and toks[j - 1].low not in _STOP_LOCAL + and toks[j - 1].end + 1 == toks[j].start + ): + label = toks[j - 1].text + label + j -= 1 + domain.insert(0, label) if len(domain) < 2: continue start_tok = j result = ".".join(d.lower() for d in domain) - # Email: "local at domain" - if j - 2 >= 0 and toks[j - 1].low in _AT: + # Email: "local at domain". A path after the domain makes it a URL ("find it online at + # acme dot com slash help"). + path_next = k + 1 < len(toks) and toks[k + 1].low in ("slash", "/") + if j - 2 >= 0 and toks[j - 1].low in _AT and not path_next: spoken = spoken or toks[j - 1].low == "at" local: list[str] = [] m = j - 2 @@ -529,6 +559,14 @@ def spoken_email_url(text: str) -> list[Edit]: result += "/" + toks[end_tok + 2].low spoken = True end_tok += 2 + # "slash pricing dash plans" -> /pricing-plans + while ( + end_tok + 2 < len(toks) + and toks[end_tok + 1].low in _PATH_JOIN + and toks[end_tok + 2].low.isalnum() + ): + result += _PATH_JOIN[toks[end_tok + 1].low] + toks[end_tok + 2].low + end_tok += 2 if not spoken: continue edits.append((toks[start_tok].start, toks[end_tok].end, result)) diff --git a/src/offrecord/redact/detectors/patterns.py b/src/offrecord/redact/detectors/patterns.py index e02635e..8251ef5 100644 --- a/src/offrecord/redact/detectors/patterns.py +++ b/src/offrecord/redact/detectors/patterns.py @@ -19,7 +19,10 @@ TLDS = ( "com|org|net|io|co|edu|gov|mil|int|uk|us|de|fr|ca|au|in|biz|info|ai|app|dev|me|ly|nl|es|it|" - "jp|ch|se|no|eu|tv|xyz|cloud|tech|example|test|invalid|local|internal|corp|ie|nz|sg|za|br|mx" + "jp|ch|se|no|eu|tv|xyz|cloud|tech|example|test|invalid|local|internal|corp|ie|nz|sg|za|br|mx|" + "health|care|clinic|dental|law|legal|insurance|bank|finance|shop|store|online|site|agency|" + "studio|solutions|services|network|digital|media|systems|group|academy|school|events|" + "travel|energy|realty|properties" ) EMAIL = re.compile(r"(? Date: Thu, 26 Nov 2026 02:42:05 -0500 Subject: [PATCH 3/3] Update results for the spoken-URL fix --- CHANGELOG.md | 3 +++ README.md | 8 ++++---- site/index.html | 8 ++++---- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d7aa87..3e93d5f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -67,6 +67,9 @@ All notable changes. Format based on Keep a Changelog. Versions are unreleased u or more digits, places listed after a place, spoken IP addresses and emails, multi-word passwords and read-back codes, URL paths, unit numbers and city/state tails of addresses, and given names that are ordinary words when they sit next to person words. +- Spoken URLs: "find it online at acme dot test slash help" is a URL, not an email, so its + path is redacted too; path words joined by "dash", domain names spoken as two words and + newer endings such as ".health" are handled. URL recall on the evaluation sets is now 100%. - Place names at Tier 0: a capitalised name redacted in part is redacted whole ("Port St. Lucie", "Dana Point"); more words that end place names ("Gold Coast", "the Panhandle"); places in text without capitals ("orange county", "salt lake city"). diff --git a/README.md b/README.md index c960000..edde29c 100644 --- a/README.md +++ b/README.md @@ -160,13 +160,13 @@ The numbers below are for the default protection (personal data): | Validation (56) / user set (8) | PII recall | PII-clean transcripts | Business context redacted or flagged | Text redacted | | --- | --- | --- | --- | --- | -| Tier 0 (rules) | 98.0% / 88.2% | 80% / 25% | 90% / 80% | 15% / 21% | -| Tier 1 (+ NER ensemble) | 98.6% / 89.5% | 86% / 25% | 97% / 82% | 17% / 23% | -| Tier 2 (+ Phi-4-mini) | 98.6% / 89.5% | 86% / 25% | 97% / 83% | 18% / 25% | +| Tier 0 (rules) | 99.3% / 88.9% | 93% / 25% | 91% / 79% | 15% / 21% | +| Tier 1 (+ NER ensemble) | 99.8% / 90.2% | 98% / 25% | 97% / 82% | 17% / 24% | +| Tier 2 (+ Phi-4-mini) | 99.8% / 90.2% | 98% / 25% | 97% / 83% | 18% / 25% | | Baseline: plain regexes | 14.2% / 7.2% | 0% / 0% | | | The user set has only 8 transcripts, so its numbers are loose: the 95% interval for Tier 0 -PII recall is 80.8-94.7% there (96.9-99.0% on validation), and its PII-clean rate could be +PII recall is 81.4-95.2% there (98.5-99.8% on validation), and its PII-clean rate could be anywhere from 0% to 62%. `offrecord eval` prints these intervals. Tier 2 does not change PII recall on these sets. What it adds is indirect identifiers: on 15 diff --git a/site/index.html b/site/index.html index 5a45b1b..1383925 100644 --- a/site/index.html +++ b/site/index.html @@ -319,15 +319,15 @@
Sealed set: 80 transcripts written blind and opened once, against targets fixed beforehand. Tier 0 missed two of them: PII recall 93.4% (target 95%) and PII-clean transcripts 46% (target 65%), almost entirely because of place names (84% caught). Names, account and card numbers, SSNs, IPs and URLs were all caught. Tier 1 reached 96.4% and 65%. Place handling has since been improved on new tuning data; the next release will be scored on a fresh sealed set.
-Read the PII-clean column first: in some transcripts a name or number still gets through, so you still read the output before sharing it. The user set has only 8 transcripts, so its numbers are loose (95% interval for Tier 0 PII recall: 80.8–94.7%). Tier 2 adds indirect identifiers rather than PII recall: on 15 held-back transcripts, descriptions of a person were redacted 63% of the time at Tier 0, 68% at Tier 1 and 78% at Tier 2. On Earnings-21 (44 real earnings calls, never tuned on) PII recall is 85.7% at Tier 0 and 89.8% at Tier 1.
+Read the PII-clean column first: in some transcripts a name or number still gets through, so you still read the output before sharing it. The user set has only 8 transcripts, so its numbers are loose (95% interval for Tier 0 PII recall: 81.4–95.2%). Tier 2 adds indirect identifiers rather than PII recall: on 15 held-back transcripts, descriptions of a person were redacted 63% of the time at Tier 0, 68% at Tier 1 and 78% at Tier 2. On Earnings-21 (44 real earnings calls, never tuned on) PII recall is 85.7% at Tier 0 and 89.8% at Tier 1.
All evaluation data is synthetic: generated conversations with invented names. It cannot capture real speech-recognition errors, real names and their spelling variety, domain jargon, cross-talk, or the clients and codenames in your deny-list. Expect real-world recall to be lower than these numbers, and review the flagged spans.