Skip to content

Commit 298a938

Browse files
author
Marcin Kardas
committed
Support negative numbers
1 parent b2ed4f4 commit 298a938

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

sota_extractor2/models/linking/bm25_naive.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +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-
number_re = re.compile(r'(^[± Ee/()^0-9.%,_+-]{2,}$)|(^[0-9]$)')
194+
number_re = re.compile(r'(^[± Ee/()^0-9.%,_+-]{2,}$)|(^\s*[0-9]\s*$)')
195195

196196
proposals = [Proposal(
197197
cell=Cell(cell_ext_id=f"{table_ext_id}/{r}.{c}",
@@ -222,7 +222,7 @@ def linked_proposals(proposals):
222222
# if first_num > 1:
223223
# first_num /= 100
224224
# format = "{x/100}"
225-
if first_num < 1 and '%' not in prop.raw_value:
225+
if 0 < first_num < 1 and '%' not in prop.raw_value:
226226
first_num *= 100
227227
format = "{100*x}"
228228
if '%' in prop.raw_value:
@@ -235,7 +235,7 @@ def linked_proposals(proposals):
235235
metric = row['metric']
236236
if metric != row['true_metric']:
237237
metric = row['true_metric']
238-
parsed = 1 - parsed if parsed < 1 else 100 - parsed
238+
parsed = 1 - parsed if 0 < parsed < 1 else 100 - parsed
239239
parsed = float(parsed)
240240

241241
linked = {

0 commit comments

Comments
 (0)