A lightweight REST API for Arabic spell checking built with FlightPHP and ArPHP library. This API provides Arabic text spell checking capabilities including misspelled word detection and correction suggestions.
- Spell Check: Detect misspelled words in Arabic text
- Correction Suggestions: Get intelligent suggestions for misspelled words
- Combined Operations: Check and suggest corrections in a single request
- API Authentication: Support for securing endpoints with API key authentication
- Error Handling: Comprehensive error responses
- PHP 7.4 or higher
- Composer
- Clone the repository:
git clone https://github.com/your-username/asc-api-sample.git
cd asc-api-sample- Install dependencies:
composer require flightphp/core
composer require khaled.alshamma/ar-php- Set your API key (for example in the routes file or environment variables)
arabic-spellcheck-api/
├── index.php # Main application file
├── routes.php # API routes definition
├── vendor/ # Composer dependencies
├── config/
│ └── config.php # Configuration file
└── README.md # This file
POST /api/spell/check
Detects misspelled words in the provided Arabic text.
Request:
{
"text": "والان وصلت الحوسبه الكمومية التي تعاتمد على فيزياء الكم"
}Response:
{
"status": "success",
"misspelled_words": [
"الحوسبه",
"تعاتمد"
]
}POST /api/spell/suggest
Provides correction suggestions for misspelled words.
Request:
{
"text": "والان وصلت الحوسبه الكمومية التي تعاتمد على فيزياء الكم"
}Response:
{
"status": "success",
"suggestions": [
{
"word": "الحوسبه",
"suggestion": [
"الحوسبة",
"الحسبه"
]
},
{
"word": "تعاتمد",
"suggestion": [
"تعتمد",
"تعامد"
]
}
]
}POST /api/spell/check-and-suggest
Combines spell checking and suggestions in a single request.
GET /api/health
Check API status (no authentication required).
Response:
{
"status": "ok"
}# Check misspelled words
curl -X POST \
http://localhost:8000/api/spell/check \
-H 'Apikey: YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{"text": "والان وصلت الحوسبه الكمومية"}'
# Get suggestions
curl -X POST \
http://localhost:8000/api/spell/suggest \
-H 'Apikey: YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{"text": "والان وصلت الحوسبه الكمومية"}'const response = await fetch('http://localhost:8000/api/spell/check', {
method: 'POST',
headers: {
'Apikey': 'YOUR_API_KEY', // if enabled
'Content-Type': 'application/json'
},
body: JSON.stringify({
text: 'والان وصلت الحوسبه الكمومية'
})
});
const result = await response.json();
console.log(result);# Development server
php -S localhost:8000 index.php
# Or use your preferred web server (Apache, Nginx)- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the LGPL License.
- ArPHP - Comprehensive Arabic language processing library
- FlightPHP - Lightweight PHP micro-framework
واجهة برمجة تطبيقات REST خفيفة للتدقيق الإملائي العربي مبنية باستخدام FlightPHP ومكتبة ArPHP. توفر هذه الواجهة قدرات للتدقيق الإملائي للنصوص العربية بما في ذلك اكتشاف الكلمات المكتوبة بشكل خاطئ واقتراح التصحيحات.
- التدقيق الإملائي: اكتشاف الكلمات المكتوبة بشكل خاطئ في النص العربي
- اقتراحات التصحيح: الحصول على اقتراحات ذكية للكلمات المكتوبة بشكل خاطئ
- العمليات المدمجة: فحص واقتراح التصحيحات في طلب واحد
- مصادقة الواجهة البرمجية: دعم تأمين نقاط الواجهة بمصادقة مفتاح API
- معالجة الأخطاء: استجابات شاملة للأخطاء
- PHP 7.4 أو أعلى
- Composer
- استنساخ المستودع:
git clone https://github.com/your-username/asc-api-sample.git
cd asc-api-sample- تثبيت التبعيات:
composer require flightphp/core
composer require khaled.alshamma/ar-php- تعيين مفتاح الواجهة البرمجية في ملف المسارات أو متغيرات البيئة.
arabic-spellcheck-api/
├── index.php # ملف التطبيق الرئيسي
├── routes.php # تعريف مسارات الواجهة البرمجية
├── vendor/ # تبعيات Composer
├── config/
│ └── config.php # ملف التكوين
└── README.md # هذا الملف
POST /api/spell/check
يكتشف الكلمات المكتوبة بشكل خاطئ في النص العربي المقدم.
الطلب:
{
"text": "والان وصلت الحوسبه الكمومية التي تعاتمد على فيزياء الكم"
}الاستجابة:
{
"status": "نجاح",
"misspelled_words": [
"الحوسبه",
"تعاتمد"
]
}POST /api/spell/suggest
يوفر اقتراحات التصحيح للكلمات المكتوبة بشكل خاطئ.
POST /api/spell/check-and-suggest
يدمج التدقيق الإملائي والاقتراحات في طلب واحد.
GET /api/health
فحص حالة الواجهة البرمجية (لا يتطلب مصادقة).
# فحص الكلمات المكتوبة بشكل خاطئ
curl -X POST \
http://localhost:8000/api/spell/check \
-H 'Apikey: YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{"text": "والان وصلت الحوسبه الكمومية"}'جميع نقاط نهاية الواجهة البرمجية (باستثناء /api/health) تتطلب مفتاح واجهة برمجية يتم تمريره في رأس Apikey.
# خادم التطوير
php -S localhost:8000 index.php
# أو استخدم خادم الويب المفضل لديك (Apache، Nginx)هذا المشروع مرخص تحت رخصة LGPL