a PHP Artificial Neural Network (ANN) to detect if a string is Persian/English using FANN library.
- Install FANN for PHP. (For guidance click here.)
- Download all files, put them together in a folder.
- Run "train_model.php". ( The script will create a file name "langDetector.net" )
- Now you can run test_model.php and give any mixed string (Persian/English) to the ANN and see the output.
I tested a string as follows:
"شناسایی زبان نوشتاری با استفاده از Artificial Neural Network و کتابخانه FANN"
The output was: ``` Array ( [0] => 0.96449780464172 [1] => -0.035985063761473 ) ``` Where indice 0 represent chance for a string to be Persian, and 1 represent the chance for a string to be English. (The script's decision was very good.)You looked at the source code? yes, your right! I could have optimized it BIG TIME! But at the time i was writing this script i just wanted the result for a paper that i was writing. So i wasn't concern about any performance issue. (If you have time, be my guest, send a request pull, i really appreciate it.)
به زودی آموزش کامل از معرفی تا نحوه استفاده از شبکههای عصبی مصنوعی به همراه آموزش کامل اجرای کدهای این مخزن را بر روی وبلاگ منتشر خواهم کرد.