cannawen / metric_units_reddit_bot

Reddit bot converting imperial units to metric units
https://www.reddit.com/user/metric_units
GNU General Public License v3.0
78 stars 34 forks source link

Refactor number parsing #100

Closed cannawen closed 6 years ago

cannawen commented 6 years ago

Create a module with a function that takes in a string (with numbers), and return an object that contains an array of

For example, input: "10,001 miles -4.56 foobar" Should return output:

[
  { startIndex: 0, endIndex: 5, number: 10001 },
  { startIndex: 13, endIndex: 17, number: -4.56 }
]

Number types supported, to start:

We should try to make each of the different types of numbers defined in their own file, so it is easy to add future kinds of numbers.

This "number standardizing" step can happen after the preprocessing step, but before the conversion step to simplify our conversion number regexes.

We can ignore conversions like "5 foot 2 inches" for now, and put that back in a separate issue (changing when the "preproccess" for each individual conversion is done)

cannawen commented 6 years ago

Closing for inactivity - Perhaps a future enhancement to look into