-
-
Notifications
You must be signed in to change notification settings - Fork 37
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
Add fix for hyperscan tokenizer #235
base: main
Are you sure you want to change the base?
Changes from all commits
894e84a
62b9cd2
a7c0422
e11c589
88cb214
81a891b
763d0f8
2ea3101
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ on: | |
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-20.04 | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,7 +52,7 @@ def short_cite_re(regex): | |
|
||
# Regex to match punctuation around volume numbers and stopwords. | ||
# This could potentially be more precise. | ||
PUNCTUATION_REGEX = r"[^\sa-zA-Z0-9]*" | ||
PUNCTUATION_REGEX = r"[^\sa-zA-Z0-9]{,3}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why make these changes? do you have examples or comments on why? |
||
|
||
# Regex for IdToken | ||
ID_REGEX = space_boundaries_re(r"id\.,?|ibid\.") | ||
|
@@ -79,7 +79,7 @@ def short_cite_re(regex): | |
) | ||
|
||
# Regex for SectionToken | ||
SECTION_REGEX = r"(\S*§\S*)" | ||
SECTION_REGEX = space_boundaries_re(r"([\w\.\,\-]*§[\w\.\,\-]*)") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. escape There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From the benchmark, it seems we are losing these?
|
||
|
||
# Regex for ParagraphToken | ||
PARAGRAPH_REGEX = r"(\n)" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -466,6 +466,9 @@ def on_match(index, start, end, flags, context): | |
start = byte_to_str_offset[start] | ||
end = byte_to_str_offset[end] | ||
m = extractor.compiled_regex.match(text[start:end]) | ||
if not m: | ||
# skip if re-run regex fails to detect match | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not expected to be common, right? |
||
continue | ||
yield extractor.get_token(m, offset=start) | ||
|
||
@property | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -630,6 +630,12 @@ def test_find_citations(self): | |
metadata={'plaintiff': 'Commonwealth', 'defendant': 'Muniz', | ||
'court': 'pa'})]), | ||
('Foo v. Bar, 1 F.Supp. 1 (SC 1967)', [case_citation(volume='1', reporter='F.Supp.', year=1967, page='1', metadata={'plaintiff': 'Foo', 'defendant': 'Bar', 'court': 'sc'})]), | ||
('Shady Grove Farms \xa0v Goldsmith Seeds 1 U.S. 1 (1981)', [ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is an example for the whitespace change; however; this was already covered by the simple r"\s" regex as pointed in the other comment. I think you should try to cover the error cases we have seen. For example would still be broken In [32]: clean_text(' \x08*\x07\x07\u038bþİ\u038b\u202cڋ\u202a-\x14V\u202c\u202c', ["all_whitespace"])
Out[32]: ' \x08*\x07\x07\u038bþİ\u038b\u202cڋ\u202a-\x14V\u202c\u202c' |
||
case_citation(year=1981, | ||
metadata={'defendant': 'Goldsmith Seeds', | ||
'plaintiff': 'Farms', | ||
'court': 'scotus'})], | ||
{'clean': ['all_whitespace']}), | ||
) | ||
# fmt: on | ||
self.run_test_pairs(test_pairs, "Citation extraction") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the only character in the list that is not included in
r"\s"
is\u200b
, so I would suggest doingWHITESPACE_REGEX = "[u200b\s]+"
or
This