Chinese numbers converter for JavaScript
Aug 29, 2017 · 1 min read

I was creating a consultant bot for a property agency, when it turned out that LUIS.ai (the AI that understands natural language) doesn’t recognize numbers like 345 萬 (it means 3,450,000 in Chinese and is often used in property prices).
This is why I’ve made a small JavaScript class that converts Chinese numbers (like 兩百四十五) into a JavaScript Number (like 245) that can be used in calculations or database queries.
For fun, I also decided to throw in support for some Cantonese slang, such as 廿yaa for 20, 卅saa for 30 and 卌sei aa for 40.
Some examples:
The code of chinese-numbers.js is in public domain on my GitHub.
