Words To Numbers: my R function
Sometimes I needed to translate character strings for numbers in the Spanish language into integer vectors representing their numeric counterpart.
It’s usually required when working in NLP projects, processing documentation, and a very required feature when processing financial data from a myriad of documents.
I’ve searched for a while, just to be sure not to re-invent the wheel but sadly, the only available option was on CRAN, a package called “English”, but for English language and doing the opposite: translating numbers to text.
So, leave me with no alternative other than coding such a function myself.
Behold, words2numbers, a function that given a dataframe full with numerical expressions in spanish text translates it into integer vectors.
it’s a quick & dirty approach, so feel free to make suggestions, corrections or dropping me a line if you find it useful.