Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ShortCaseCitation.full_span now includes parentheticals #183

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading