Skip to content
Open
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 numerizer/numerizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ def cleanup_fractions(s):
pat = re.compile(r'(\d+)(?: | and |-)+(<num>|\s)*(\d+)\s*\/\s*(\d+)',
flags=re.IGNORECASE)
m = re.search(pat, s)
if m is not None:
if m is not None and float(m.group(4)) != 0.0:
def _repl_frac_cleanup(m):
return str(float(m.group(1)) + (float(m.group(3)) / float(m.group(4))))
s = re.sub(pat, _repl_frac_cleanup, s)
Expand Down
1 change: 1 addition & 0 deletions test_numerize.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ def test_ambiguous_cases():
# assert 'the 2nd second' == numerize('the second second')
# assert 'the 4th second' == numerize('the fourth second')
# assert '1 second' == numerize('one second')
assert "0-4/0" == numerize("0-4/0")


# TODO: Find way to distinguish this verb
Expand Down