问题
In Persian and Arabic alphabet we have some letters that has different shape but their sounds are so close together.
These are list of those letters:
S= س, ص, ث
Gh= غ , ق
T= ت,ط
Z= ز , ض, ظ, ذ
H= ح , ه
Many people don't know how to write words or forget the spelling and write the words wrong.
For example for the word دغدغه it can be write in 8 ways:
1: دقدغه 2: دقدغح 3: دقدقه 4: دقدقح 5: دغدغه 6: دغدغح 7: دغدقه 8: دغدقح
How can I count how many ways a user can type a word wrong?
Is there any function for doing this in PHP?
回答1:
You can do this by Combination (mathematic) that is a way of selecting items from a collection, such that (unlike permutations) the order of selection does not matter.
Learn more
How to count number of combinations?
As you see in image, you know the number of each letters different types, just multiple the number of founded letters in word by the number of different types of that letter. Here for the word what you said we have 8 results.
And for the second question: Yes, there is a function for this on GitHub and see the demo of that repository, and you can test your words there.
来源:https://stackoverflow.com/questions/35748694/how-to-find-mistyping-in-arabic-and-persian-language