This is much easier to do in Arabic than for example English. That is because Arabic is basically phonetic. There are some very small exceptions which have highly regular rules so they should be easy to handle. For example:
- Harf Shamsia ... Al + (n, t, d, dh, l, s, sh) the "l" assimilates to the first letter of the word that follows.
- Harf Qamaria ... Al + (anything else), the "l" sound remains.
Here is a simple look up table. (Presumably, you read Arabic, or have someone to help you with that?). You will need to be careful to take into account the text encoding type of your Arabic source, is it Unicode (and what type of unicode encoding), or code page 1256?
That should be enough to get you started. Good success!