From 460a7d7bc5706023cacb73652e3c7226d304f02a Mon Sep 17 00:00:00 2001
From: mlissner Return hash that will be the same if two cites are semantically
-equivalent.Module
"""
try:
return fast_diff_match_patch.diff(
- a, b, timelimit=0, checklines=False, cleanup="No",
+ a, b, timelimit=0, checklines=False, cleanup="No"
)
except AttributeError as e:
raise AttributeError(
diff --git a/models.html b/models.html
index 84e354c..d7ddb33 100644
--- a/models.html
+++ b/models.html
@@ -111,6 +111,9 @@ eyecite.annotate
Module
if isinstance(self.metadata, dict)
else self.Metadata()
)
+ # Set known missing page numbers to None
+ if re.search("^_+$", self.groups.get("page", "") or ""):
+ self.groups["page"] = None
def __repr__(self):
"""Simplified repr() to be more readable than full dataclass repr().
@@ -131,8 +134,12 @@ eyecite.models
Module
def comparison_hash(self) -> int:
"""Return hash that will be the same if two cites are semantically
- equivalent."""
- return hash((type(self), tuple(self.groups.items())))
+ equivalent, unless the citation is a CaseCitation missing a page.
+ """
+ if isinstance(self, CaseCitation) and self.groups["page"] is None:
+ return id(self)
+ else:
+ return hash((type(self), tuple(self.groups.items())))
def corrected_citation(self):
"""Return citation with any variations normalized."""
@@ -642,7 +649,12 @@ eyecite.models
Module
def __hash__(self):
"""Resources are the same if their citations are semantically
- equivalent."""
+ equivalent.
+
+ Note: Resources composed of citations with missing page numbers are
+ NOT considered the same, even if their other attributes are identical.
+ This is to avoid potential false positives.
+ """
return self.citation.comparison_hash()
def __eq__(self, other):
@@ -771,7 +783,7 @@ eyecite.models
Inherited members
Metadata
add_metadata
comparison_hash
comparison_hash
corrected_citation
corrected_citation_full
corrected_reporter
Inherited members
if isinstance(self.metadata, dict)
else self.Metadata()
)
+ # Set known missing page numbers to None
+ if re.search("^_+$", self.groups.get("page", "") or ""):
+ self.groups["page"] = None
def __repr__(self):
"""Simplified repr() to be more readable than full dataclass repr().
@@ -838,8 +853,12 @@ Inherited members
def comparison_hash(self) -> int:
"""Return hash that will be the same if two cites are semantically
- equivalent."""
- return hash((type(self), tuple(self.groups.items())))
+ equivalent, unless the citation is a CaseCitation missing a page.
+ """
+ if isinstance(self, CaseCitation) and self.groups["page"] is None:
+ return id(self)
+ else:
+ return hash((type(self), tuple(self.groups.items())))
def corrected_citation(self):
"""Return citation with any variations normalized."""
@@ -919,15 +938,19 @@ Methods
def comparison_hash(self) -> int:
"""Return hash that will be the same if two cites are semantically
- equivalent."""
- return hash((type(self), tuple(self.groups.items())))
+ equivalent, unless the citation is a CaseCitation missing a page.
+ """
+ if isinstance(self, CaseCitation) and self.groups["page"] is None:
+ return id(self)
+ else:
+ return hash((type(self), tuple(self.groups.items())))
@@ -1325,7 +1348,7 @@ Inherited members
Metadata
add_metadata
-comparison_hash
+comparison_hash
corrected_citation
corrected_reporter
dump
@@ -1392,7 +1415,7 @@ Inherited members
Metadata
add_metadata
-comparison_hash
+comparison_hash
corrected_citation
corrected_citation_full
corrected_reporter
@@ -1473,7 +1496,7 @@ Inherited members
Metadata
add_metadata
-comparison_hash
+comparison_hash
corrected_citation
corrected_citation_full
corrected_reporter
@@ -1565,7 +1588,7 @@ Inherited members
Metadata
add_metadata
-comparison_hash
+comparison_hash
corrected_citation
corrected_citation_full
corrected_reporter
@@ -1856,7 +1879,12 @@ Class variables
def __hash__(self):
"""Resources are the same if their citations are semantically
- equivalent."""
+ equivalent.
+
+ Note: Resources composed of citations with missing page numbers are
+ NOT considered the same, even if their other attributes are identical.
+ This is to avoid potential false positives.
+ """
return self.citation.comparison_hash()
def __eq__(self, other):
@@ -2010,6 +2038,22 @@ Methods
self.guess_edition()
+
+def comparison_hash(self) ‑> int
+
Return hash that will be the same if two cites are semantically +equivalent.
def comparison_hash(self) -> int:
+ """Return hash that will be the same if two cites are semantically
+ equivalent."""
+ return hash((super().comparison_hash(), self.all_editions))
+
def corrected_citation(self)
CitationBase
:
Metadata
comparison_hash
corrected_citation_full
dump
matched_text
Metadata
add_metadata
comparison_hash
comparison_hash
corrected_citation
corrected_reporter
dump
add_metadata
all_editions
+comparison_hash
corrected_citation
corrected_reporter
edition_guess
diff --git a/resolve.html b/resolve.html
index 60c74f1..2e1d1ba 100644
--- a/resolve.html
+++ b/resolve.html
@@ -116,6 +116,13 @@ Module eyecite.resolve
) -> bool:
"""Return True if id_cite has a pin cite that can't be correct for the
given full_cite."""
+ # if full cite has a known missing page, this pin cite can't be correct
+ if (
+ type(full_cite) is FullCaseCitation
+ and full_cite.groups.get("page") is None
+ ):
+ return True
+
# if no pin cite, we're fine
if not id_cite.metadata.pin_cite:
return False