Skip to content

Commit

Permalink
Add support for empty values of range_end column
Browse files Browse the repository at this point in the history
  • Loading branch information
mtlynch committed May 1, 2018
1 parent bc73ffa commit ab11559
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion ingredient_phrase_tagger/training/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,17 @@ def _parse_row(row):
that any of its values that contain a number (e.g. "6.4") are
converted to floats and the 'index' value is converted to an int.
"""
# Certain rows have range_end set to empty.
if row['range_end'] == '':
range_end = 0.0
else:
range_end = float(row['range_end'])

return {
'input': row['input'].decode('utf-8'),
'name': row['name'].decode('utf-8'),
'qty': float(row['qty']),
'range_end': float(row['range_end']),
'range_end': range_end,
'unit': row['unit'].decode('utf-8'),
'comment': row['comment'].decode('utf-8'),
}

0 comments on commit ab11559

Please sign in to comment.