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

Parse number abbreviations [#46] #73

Closed nicolasferraro closed 6 years ago

nicolasferraro commented 6 years ago

closes #46

This adds a comment preprocessor that expands number abbreviations to the full form (eg 4.5k -> 4500). Supporting more abbreviations should be easy now, just add the abbreviation: value pair into the abbreviations object.

nicolasferraro commented 6 years ago

Hey @cannawen sorry It took so long, I've made the changes requested.

The preprocessing was moved to a new module called preprocess.js and the test cases have been moved to preprocess-test.js. The module exports a single function called preprocessComment which applies every function registered in the preprocessFunction array.

I also took the liberty of modifying the fractionProccesor code a bit to fix some eslint errors.