Skip to content

Commit

Permalink
Added support for dash-splitted 2-digit numbers. Like thirty-five
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Ledovsky committed Jun 7, 2016
1 parent 100fe8b commit 3ef2d78
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion unit_testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def test_output(self):
self.assertEqual(w2n.word_to_num('eleven'),11)
self.assertEqual(w2n.word_to_num('nineteen billion and nineteen'),19000000019)
self.assertEqual(w2n.word_to_num('one hundred and forty two'),142)
self.assertEqual(w2n.word_to_num('one hundred thirty-five'),135)

if __name__ == '__main__':
unittest.main()
unittest.main()
1 change: 1 addition & 0 deletions word2number/w2n.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"""
def word_to_num(number_sentence):
number_sentence = number_sentence.lower()
number_sentence = number_sentence.replace('-', ' ')
split_words = number_sentence.split() # split sentence into words
clean_numbers = [] # removing and, & etc.
for word in split_words:
Expand Down

0 comments on commit 3ef2d78

Please sign in to comment.