Glued citations (`846F.2d746`): relax whitespace at the full-cite template boundaries -- completes #305
Summary
I'm building citation-verification tooling on top of eyecite (checking legal filings for fabricated/unverifiable citations) and hit a class of real-world citations that extract as nothing.
eyecite requires exactly one literal space at the volume-reporter and
reporter-page boundaries, so a "glued" citation -- 846F.2d746,
410U.S.113 -- produces no match at all. #305/#307 relaxed whitespace
within reporter abbreviations; the two template boundaries are the
remaining rigid seams. This proposal extends the same \s* relaxation to
them.
The downstream failure mode is a false negative: a verifier reports "0 problems found" on a document whose citations it never saw, and glued citations are missing from any citation graph built with eyecite.
Prevalence
From a scan of the full CourtListener bulk opinion export (10,798,347
opinions): 7,740 opinions contain glued citations (10,488 matches,
4,683 distinct strings). Two provenances: OCR-introduced, and born-digital
(a 2016 S.D. Tex. filing carries 42U.S.C. §1981 in the PDF's own text
layer, next to correctly-spaced 42 U.S.C. § 2000e). Glue also
propagates: 846F.2d746 appears in 68 distinct RECAP filings via
copy-paste. I can contribute document IDs + context windows as regression
fixtures.
Root cause
_relax_ws (#307) applies only to edition names; the template keeps
literal spaces at the boundaries:
raw_regex_variables["full_cite"][""] = "$volume $reporter,? $page" # tokenizers.py L138
Proposed change
raw_regex_variables["full_cite"][""] = r"$volume\s*$reporter,?\s*$page"
plus trimming the trailing \s* in _relax_ws output. The trim is
load-bearing: without the mandatory boundary space, the greedy \s*
after a reporter's final period captures the following space into the
reporter group (reporter='U.S. '), breaking every consumer of the
groups (~190 test failures). With the trim, the test-suite failure set is
byte-identical to master on my environment.
| input | master | patched |
|---|---|---|
846F.2d746 |
(none) | FullCaseCitation |
410 U.S. 113 |
FullCaseCitation | unchanged |
799 N. Y. S. 2d 795 (#305 style) |
FullCaseCitation | unchanged |
7F., No. 106, Sec. 5 (address) |
(none) | (none) |
Measured gains / costs
Replaying master vs patched over the stored context windows of all 7,740 hit documents (11,748 windows):
- Gains: 7,737 new citations across 4,141 documents; 87% carry
plausible volumes (
846F.2d746,443U.S.307,550U.S. 544, short cites like757F.2d at 1241). - Cost: 13% have implausible volumes -- digit fusion (
544,1127S. Ct. 1955; true cite127 S. Ct. 1955): a digit glued ahead of the volume is absorbed into it, and no tokenizer rule can recover the split. All of these occur where master extracts nothing, and an implausible volume fails any downstream lookup -- a visible wrong guess replacing an invisible miss. Volume-plausibility gating would live in validation; I'd scope it as a follow-up. - Losses: effectively zero -- 8 overlap swaps (recovered cite retires
a redundant
SupraCitation), 4 garbageUnknownCitationblobs replaced by real parses, 1 double-glue pathology (347U.S. 483,349 U.S. 294: first cite recovered, its pin-cite parser swallows the second's volume).
Out of scope: statute glue (42U.S.C.§1983) rides the laws templates and
still degrades to UnknownCitation -- separate issue, likely reporters-db.
I have the patch and replay tooling ready and am happy to open a PR.
Adding evidence from a different provenance for the same two seams: PDF line wrapping rather than OCR glue.
I hit this building table-of-authorities tooling over eyecite. The rule looks like exactly one literal space — anything else at the volume|reporter or reporter|page boundary yields no citation at all:
separator in 329[?]So. 3d 148 |
result |
|---|---|
| single space | found |
| two spaces | lost |
| tab | lost |
| newline | lost |
| space + newline + space | lost |
| glued (no space) | lost |
Same at the reporter|page seam. Breaks elsewhere are tolerated: inside the reporter abbreviation (So.\n3d, presumably from #305), in the case name, before the volume, and before the parenthetical (which degrades to metadata loss, #297).
import eyecite
from eyecite.models import FullCaseCitation
def found(t):
return bool([c for c in eyecite.get_citations(t) if isinstance(c, FullCaseCitation)])
found("Doe v. Acme Ins. Co., 329 So. 3d 148 (Fla. 2d DCA 2021).") # True
found("Doe v. Acme Ins. Co., 329\nSo. 3d 148 (Fla. 2d DCA 2021).") # False
found("Doe v. Acme Ins. Co., 329 So. 3d 148 (Fla. 2d DCA 2021).") # False
found("Doe v. Acme Ins. Co., 329 So. 3d\n148 (Fla. 2d DCA 2021).") # False
The tokenizer confirms this is the template match rather than #297's ParagraphToken scanning issue — with one space the citation becomes a single CitationToken; with a newline it never becomes one:
'329 So. 3d 148' -> ['CitationToken']
'329\nSo. 3d 148' -> ['str', 'ParagraphToken', 'str', 'str', 'str', 'str', 'str']
Why this strengthens the \s* proposal: wrapped citations are plausibly more common than glued ones. Every citation extracted from a filed PDF is subject to the right margin, and citations are long enough to wrap often. In an 8-page test brief with 5 authorities, one full citation vanished to a single wrap at the volume|reporter seam — and a verifier then reports "no problems found" for a citation it never saw.
One \s* at both boundaries covers glued, wrapped, double-spaced and tab-separated in a single change. Happy to contribute the whitespace variants above as regression fixtures.