Friday, November 8, 2013

An algorithm for parsing the numeric representation of a number into its grammatically correct literal representation in Arabic



Few months ago I was asked to develop a software for an elementary school, one of required features was printing students grade-sheet, the official form used for presenting student's marks requires each subject marks to be written in numbers and in words.
So the application should be able to convert student's marks -stored in the database as numbers- to words when printing a grade-sheet.
Fortunately few years ago and during my free time I developed an algorithm for converting  numbers from numeric representation to words. so programming that feature was not a big problem to me.

That algorithm was really a good work : it can parse numbers of any size up to 19 figure, supports fractions, its output is grammatically correct and supports both feminine and masculine numbers (Yes, in Arabic the pronunciation of a number differs between feminine and masculine entities e.g. thirteen in thirteen trees is written ثلاث عشرة while in thirteen doors is written ثلاثة عشر , because in Arabic tree is feminine and door is masculine).

Here I share it with you!