Skip to content

Commit

Permalink
ShortCaseCitation.full_span now includes paren.
Browse files Browse the repository at this point in the history
  • Loading branch information
varun-magesh committed Aug 26, 2024
1 parent b66cefd commit 4abdc2b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
19 changes: 16 additions & 3 deletions eyecite/find.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def _extract_shortform_citation(

# Get pin_cite
cite_token = cast(CitationToken, words[index])
pin_cite, span_end, parenthetical = extract_pin_cite(
pin_cite, span_end, full_span_end, parenthetical = extract_pin_cite(
words, index, prefix=cite_token.groups["page"]
)

Expand All @@ -186,6 +186,12 @@ def _extract_shortform_citation(
exact_editions=cite_token.exact_editions,
variation_editions=cite_token.variation_editions,
span_end=span_end,
full_span_start=(
index
if not antecedent_guess
else index - 1 + m.start()
),
full_span_end=full_span_end,
metadata={
"antecedent_guess": antecedent_guess,
"pin_cite": pin_cite,
Expand All @@ -212,7 +218,7 @@ def _extract_supra_citation(
Supra 3: Adarand, supra, somethingelse
Supra 4: Adrand, supra. somethingelse
"""
pin_cite, span_end, parenthetical = extract_pin_cite(words, index)
pin_cite, span_end, full_span_end, parenthetical = extract_pin_cite(words, index)
antecedent_guess = None
volume = None
m = match_on_tokens(
Expand All @@ -231,6 +237,12 @@ def _extract_supra_citation(
cast(SupraToken, words[index]),
index,
span_end=span_end,
full_span_start=(
index
if not antecedent_guess
else index - 1 + m.start()
),
full_span_end=full_span_end,
metadata={
"antecedent_guess": antecedent_guess,
"pin_cite": pin_cite,
Expand All @@ -248,11 +260,12 @@ def _extract_id_citation(
immediately succeeding tokens to construct and return an IdCitation
object.
"""
pin_cite, span_end, parenthetical = extract_pin_cite(words, index)
pin_cite, span_end, full_span_end, parenthetical = extract_pin_cite(words, index)
return IdCitation(
cast(IdToken, words[index]),
index,
span_end=span_end,
full_span_end=full_span_end,
metadata={
"pin_cite": pin_cite,
"parenthetical": parenthetical,
Expand Down
1 change: 1 addition & 0 deletions eyecite/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ def extract_pin_cite(
return (
pin_cite,
from_token.end + extra_chars - len(prefix),
from_token.end + m.end(),
parenthetical,
)
return None, None, None
Expand Down

0 comments on commit 4abdc2b

Please sign in to comment.