Skip to content

Commit 9d2c329

Browse files
committed
tests(tests): Add a few more tests
More edge case examples
1 parent 49ccc24 commit 9d2c329

File tree

3 files changed

+56
-6
lines changed

3 files changed

+56
-6
lines changed

eyecite/helpers.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -206,12 +206,12 @@ def add_defendant(citation: CaseCitation, document: Document) -> None:
206206
and document.plain_to_markup
207207
and document.markup_to_plain
208208
):
209-
new_text = update_defendant_markup(document, stop_word)
209+
new_defendant = update_defendant_markup(document, stop_word).strip()
210210
if (
211-
citation.metadata.defendant != new_text
212-
and new_text is not None
211+
citation.metadata.defendant != new_defendant
212+
and new_defendant != ""
213213
):
214-
citation.metadata.defendant = new_text
214+
citation.metadata.defendant = new_defendant
215215

216216

217217
def add_pre_citation(citation: FullCaseCitation, document: Document) -> None:
@@ -545,7 +545,7 @@ def update_defendant_markup(
545545
Returns: New defendant text if any
546546
"""
547547
if not document.plain_to_markup or not document.markup_to_plain:
548-
return None
548+
return ""
549549

550550
# add 3 char to account for the star pagination whitespace
551551
# <i>United States</i> v. <i>Carignan,</i> <span class="star-pagination">
@@ -560,11 +560,12 @@ def update_defendant_markup(
560560
defendant_end = document.markup_to_plain.update(
561561
filtered_results[0][2], bisect_right
562562
)
563+
563564
defendant_start = (
564565
stop_word.start + len(stop_word.groups["stop_word"]) + 1
565566
)
566567
return document.plain_text[defendant_start:defendant_end].strip(" ,")
567-
return None
568+
return ""
568569

569570

570571
joke_cite: List[CitationBase] = [

eyecite/regexes.py

+1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ def short_cite_re(regex):
7070
"aff'd",
7171
"affirmed",
7272
"remanded",
73+
"see also",
7374
"see",
7475
"granted",
7576
"dismissed",

tests/test_FindTest.py

+48
Original file line numberDiff line numberDiff line change
@@ -1534,5 +1534,53 @@ def test_markup_plaintiff_and_antecedent_guesses(self) -> None:
15341534
],
15351535
{"clean_steps": ["html", "all_whitespace"]},
15361536
),
1537+
# can we remove see also
1538+
(
1539+
"""<em>see also Cass v. Stephens</em>,\r\n156 S.W.3d 38""",
1540+
[
1541+
case_citation(
1542+
page="38",
1543+
volume="156",
1544+
reporter="S.W.3d",
1545+
short=False,
1546+
metadata={
1547+
"plaintiff": "Cass",
1548+
"defendant": "Stephens",
1549+
},
1550+
),
1551+
],
1552+
{"clean_steps": ["html", "all_whitespace"]},
1553+
),
1554+
# technically this is incorrect in determing plaintiff/defendant but we have no way to deal with that
1555+
(
1556+
""" <i>See </i><i>Loup-Miller Const. Co. v. City and County of Denver,</i> 676 P.2d 1170 (Colo.1984) .... <i>See </i><i>Loup-Miller,</i> 676 P.2d 1170 and so on <i>Loup-Miller</i>""",
1557+
[
1558+
case_citation(
1559+
page="1170",
1560+
volume="676",
1561+
reporter="P.2d",
1562+
short=False,
1563+
metadata={
1564+
"plaintiff": "Loup-Miller Const. Co.",
1565+
"defendant": "City and County of Denver",
1566+
},
1567+
),
1568+
case_citation(
1569+
page="1170",
1570+
volume="676",
1571+
reporter="P.2d",
1572+
short=False,
1573+
metadata={
1574+
"defendant": "Loup-Miller",
1575+
},
1576+
),
1577+
reference_citation(
1578+
"Loup-Miller",
1579+
metadata={"defendant": "Loup-Miller"},
1580+
),
1581+
],
1582+
{"clean_steps": ["html", "all_whitespace"]},
1583+
),
15371584
)
15381585
self.run_test_pairs(test_pairs, "Citation extraction")
1586+

0 commit comments

Comments
 (0)