Skip to content

Commit

Permalink
fix bug where infinity could be extracted as number
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanathan committed Apr 26, 2019
1 parent 2623431 commit 8c1ad2c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion epitator/raw_number_annotator.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from .date_annotator import DateAnnotator
from . import utils
import re
import math


def is_valid_number(num_string):
Expand All @@ -15,7 +16,7 @@ def is_valid_number(num_string):
if num_string[0] == '0' and len(num_string) > 1:
return False
value = utils.parse_spelled_number(num_string)
return value is not None
return value not in [None, math.inf]


class RawNumberAnnotator(Annotator):
Expand Down
4 changes: 4 additions & 0 deletions tests/annotator/test_count_annotator.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,10 @@ def test_count_list(self):
if 'case' in count.metadata['attributes']]
self.assertSequenceEqual(actual_counts, expected_counts)

def test_infinity(self):
doc = AnnoDoc("Nmult 22-InF cases of Ebola.")
doc.add_tier(self.annotator)


if __name__ == '__main__':
unittest.main()

0 comments on commit 8c1ad2c

Please sign in to comment.