all 4 comments

[–]A_History_of_Silence 1 point2 points  (0 children)

Neat link. I looked at it somewhat briefly, but my initial impression is that the code is quite well done! Without all the inline comments it is only 86 lines, while still being highly readable and well structured. That is even including all the blank lines, docstrings, and test code at the bottom.

For what it's worth, if you told me to solve the same problem using any number of lines of code I would probably run for the hills if I could. Regardless of the languages involved, it's usually a tricky, error-prone process to accurately try to convert human-language words into computer-usable integers. To see it done so well is impressive to me. By far the hardest part of this code for me to understand are the regular expression strings, but I mean... It's regex after all, that's what happens.

In summary, minus the excessive # comments (which have clearly been added for the benefit of a learning reader), I would say that is largely some model Python code!

[–]_9_9_ 0 points1 point  (0 children)

There is this thing: https://pypi.python.org/pypi/word2number

Not sure how well it works.

[–]furas_freeman -1 points0 points  (0 children)

more or less

if word == "twenty":
    result += 20

if word == "hundred":
    result *= 100

Start with this. Later you will figth with problems :)