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

bug fix for citator #1855

Merged
merged 1 commit into from
Nov 2, 2023
Merged
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
2 changes: 1 addition & 1 deletion indigo/analysis/refs/provisions.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ def get_target_from_text(self, match: re.Match, target: Union[str, None]) -> (Un
if target == "thereof":
# look backwards - find the first citation before the start of this match
for c in reversed(citations):
if c.end_pos < match.start():
if c.end < match.start():
frbr_uri = c.href
break

Expand Down
12 changes: 12 additions & 0 deletions indigo/tests/test_provision_refs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1290,6 +1290,18 @@ def test_markup_text(self):
ExtractedCitation("26(a)", 28, 33, "/akn/za/act/2009/1/~sec_26__subsec_a", 0, 'According to section 26 and ', ' of Act No. 1 of 2009.'),
], self.finder.citations)

def test_markup_text_thereof(self):
text = """Regarding Act No. 1 of 2009 and section 26 thereof."""
self.finder.setup(self.frbr_uri, text=text)
self.finder.citations = [
ExtractedCitation("Act No. 1 of 2009", 10, 27, "/akn/za/act/2009/1", 0, 'Regarding ', ' and section' ),
]
self.finder.extract_paged_text_matches()
self.assertEqual([
ExtractedCitation("Act No. 1 of 2009", 10, 27, "/akn/za/act/2009/1", 0, 'Regarding ', ' and section' ),
ExtractedCitation("26", 40, 42, "/akn/za/act/2009/1/~sec_26", 0, 'Act No. 1 of 2009 and section ', ' thereof.' ),
], self.finder.citations)

def test_markup_text_mixed_page_numbers(self):
text = """Reference to Act No. 1 of 2009.\x0COn a new page section 26 of Act No. 1 of 2009.\x0CAct No. 1 of 2009."""
self.finder.setup(self.frbr_uri, text=text)
Expand Down
Loading