Skip to content

Commit 3149415

Browse files
author
Marcin Kardas
committed
Support commas in numeric cells
1 parent 403a53c commit 3149415

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

sota_extractor2/models/linking/bm25_naive.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,7 @@ def annotations(r, c, type='model'):
191191
if type in structure[nr, c]:
192192
yield Value(structure[nr, c], matrix[nr, c])
193193

194-
195-
number_re = re.compile(r'^[± Ee /()^0-9.%±_-]{2,}$')
194+
number_re = re.compile(r'^[± Ee/()^0-9.%,_+-]{2,}$')
196195

197196
proposals = [Proposal(
198197
cell=Cell(cell_ext_id=f"{table_ext_id}/{r}.{c}",

sota_extractor2/models/linking/format.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ def format_to_regexp(format):
2929
return re.compile('^' + regexp), fn
3030

3131
def extract_value(cell_value, format):
32-
cell_value = re.sub(r"\s+%", "%", cell_value)
32+
cell_value = re.sub(r"\s+%", "%", cell_value).replace(",", "").strip()
3333
regexp, fn = format_to_regexp(format)
34-
match = regexp.match(cell_value.strip())
34+
match = regexp.match(cell_value)
3535
if match is None or not len(match.groups()):
3636
return Decimal('NaN')
37-
return fn(Decimal(match.group(1)))
37+
return fn(Decimal(match.group(1)))

0 commit comments

Comments
 (0)