finnfiddle / words-to-numbers

JS library to convert textual words to numbers with optional fuzzy text matching
MIT License
248 stars 57 forks source link

option to preserve ordinal suffixes #29

Closed arizzitano closed 2 years ago

arizzitano commented 5 years ago

By default, wordsToNumbers converts ordinal number words to plain numbers:

wordsToNumbers('One Hundred Sixteenth Congress'); // 116 Congress

This PR adds an option preserveOrdinals to retain the ordinal suffixes, which can be useful for preserving semantic meaning within longer strings:

wordsToNumbers('One Hundred Sixteenth Congress', { preserveOrdinals: true }); // 116th Congress

Thanks for your work on this library!