Skip to content

تطبيق بسيط لواجهة تصحيح إملائي باستخدام النسخة مفتوحة المصدر من المصحح وإطار FlightPHP

License

Notifications You must be signed in to change notification settings

AlMosahih-ASC/asc-api-sample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

المُصَحِّح ASC

Al-Mosahih ASC REST API | واجهة المُصَحِّح لبرمجة التطبيقات

العربية | English


English

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.

Features

  • 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

Requirements

  • PHP 7.4 or higher
  • Composer

Installation

  1. Clone the repository:
git clone https://github.com/your-username/asc-api-sample.git
cd asc-api-sample
  1. Install dependencies:
composer require flightphp/core
composer require khaled.alshamma/ar-php
  1. Set your API key (for example in the routes file or environment variables)

Project Structure

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

API Endpoints

1. Check Misspelled Words

POST /api/spell/check

Detects misspelled words in the provided Arabic text.

Request:

{
  "text": "والان وصلت الحوسبه الكمومية التي تعاتمد على فيزياء الكم"
}

Response:

{
  "status": "success",
  "misspelled_words": [
    "الحوسبه",
    "تعاتمد"
  ]
}

2. Get Correction Suggestions

POST /api/spell/suggest

Provides correction suggestions for misspelled words.

Request:

{
  "text": "والان وصلت الحوسبه الكمومية التي تعاتمد على فيزياء الكم"
}

Response:

{
  "status": "success",
  "suggestions": [
    {
      "word": "الحوسبه",
      "suggestion": [
        "الحوسبة",
        "الحسبه"
      ]
    },
    {
      "word": "تعاتمد",
      "suggestion": [
        "تعتمد",
        "تعامد"
      ]
    }
  ]
}

3. Check and Suggest (Combined)

POST /api/spell/check-and-suggest

Combines spell checking and suggestions in a single request.

4. Health Check

GET /api/health

Check API status (no authentication required).

Response:

{
  "status": "ok"
}

Usage Examples

Using cURL

# 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": "والان وصلت الحوسبه الكمومية"}'

Using JavaScript/Fetch

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);

Running the Application

# Development server
php -S localhost:8000 index.php

# Or use your preferred web server (Apache, Nginx)

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the LGPL License.

Acknowledgments

  • ArPHP - Comprehensive Arabic language processing library
  • FlightPHP - Lightweight PHP micro-framework

العربية

واجهة برمجة تطبيقات REST خفيفة للتدقيق الإملائي العربي مبنية باستخدام FlightPHP ومكتبة ArPHP. توفر هذه الواجهة قدرات للتدقيق الإملائي للنصوص العربية بما في ذلك اكتشاف الكلمات المكتوبة بشكل خاطئ واقتراح التصحيحات.

المميزات

  • التدقيق الإملائي: اكتشاف الكلمات المكتوبة بشكل خاطئ في النص العربي
  • اقتراحات التصحيح: الحصول على اقتراحات ذكية للكلمات المكتوبة بشكل خاطئ
  • العمليات المدمجة: فحص واقتراح التصحيحات في طلب واحد
  • مصادقة الواجهة البرمجية: دعم تأمين نقاط الواجهة بمصادقة مفتاح API
  • معالجة الأخطاء: استجابات شاملة للأخطاء

المتطلبات

  • PHP 7.4 أو أعلى
  • Composer

التثبيت

  1. استنساخ المستودع:
git clone https://github.com/your-username/asc-api-sample.git
cd asc-api-sample
  1. تثبيت التبعيات:
composer require flightphp/core
composer require khaled.alshamma/ar-php
  1. تعيين مفتاح الواجهة البرمجية في ملف المسارات أو متغيرات البيئة.

هيكل المشروع

arabic-spellcheck-api/
├── index.php           # ملف التطبيق الرئيسي
├── routes.php          # تعريف مسارات الواجهة البرمجية
├── vendor/             # تبعيات Composer
├── config/
│   └── config.php      # ملف التكوين
└── README.md           # هذا الملف

نقاط نهاية الواجهة البرمجية

1. فحص الكلمات المكتوبة بشكل خاطئ

POST /api/spell/check

يكتشف الكلمات المكتوبة بشكل خاطئ في النص العربي المقدم.

الطلب:

{
  "text": "والان وصلت الحوسبه الكمومية التي تعاتمد على فيزياء الكم"
}

الاستجابة:

{
  "status": "نجاح",
  "misspelled_words": [
    "الحوسبه",
    "تعاتمد"
  ]
}

2. الحصول على اقتراحات التصحيح

POST /api/spell/suggest

يوفر اقتراحات التصحيح للكلمات المكتوبة بشكل خاطئ.

3. الفحص والاقتراح (مدمج)

POST /api/spell/check-and-suggest

يدمج التدقيق الإملائي والاقتراحات في طلب واحد.

4. فحص الحالة

GET /api/health

فحص حالة الواجهة البرمجية (لا يتطلب مصادقة).

أمثلة الاستخدام

استخدام cURL

# فحص الكلمات المكتوبة بشكل خاطئ
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

الشكر والتقدير

  • ArPHP - مكتبة شاملة لمعالجة اللغة العربية
  • FlightPHP - إطار عمل PHP مصغر وخفيف

About

تطبيق بسيط لواجهة تصحيح إملائي باستخدام النسخة مفتوحة المصدر من المصحح وإطار FlightPHP

Topics

Resources

License

Stars

Watchers

Forks

Languages