Closed FredG71 closed 9 years ago
Using static values and multiplication/division to handle conversion may not be not a bad idea in and of itself, but maintaining such a table could quickly turn out to be a mess. Duckduckgo also gives access to more than just lengths, it can try and guess abbreviations/multiple spellings etc.
A better way of extracting "tokens" - each group denoted by ()
can be captured by using match.group(N)
where N is the number of the match. For example:
>>> match = re.search(r'([a-z]+) ([A-Z]+)', 'abc ABC')
>>> match.group(1)
'abc'
>>> match.group(2)
'ABC'
There's probably a better way to handle that, but using duckduckgo either gave incorrect results or simply didn't work, besides using duckduckgo to handle that was probably not needed imo considering that the conversion constants never actually change.