PHPackages                             helturkey/mosab-qafya-detector - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. helturkey/mosab-qafya-detector

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

helturkey/mosab-qafya-detector
==============================

PHP-first classical Arabic qafya detector with Laravel support, scholarly response models, fixtures, and tests.

v0.1.0(2mo ago)015MITPHP ^8.4

Since May 3Compare

[ Source](https://github.com/helturkey/mosab-qafya-detector)[ Packagist](https://packagist.org/packages/helturkey/mosab-qafya-detector)[ RSS](/packages/helturkey-mosab-qafya-detector/feed)WikiDiscussions Synced 3w ago

READMEChangelog (1)Dependencies (4)Versions (2)Used By (0)

Mosab Qafya Detector
====================

[](#mosab-qafya-detector)

**Mosab Qafya Detector** is a PHP-first package for Arabic qafya detection. It extracts the core rhyme letter (**rawi**), qafya components such as **radf**, **wasl**, **khurooj**, **taasis**, and **dakhiil**, and provides poem-level analysis with diagnostics, clusters, defects, sanad, and review flags.

> This is a production-ready machine-assisted qafya detector. It is not a replacement for human scholarly verification in ambiguous poems.

---

Installation
------------

[](#installation)

```
composer require helturkey/mosab-qafya-detector
```

---

Quick Usage
-----------

[](#quick-usage)

```
use Mosab\QafyaDetector\QafyaDetector;

$result = QafyaDetector::make()->extract('ناداها');

$result->rawi();           // ه
$result->radf();           // ا
$result->wasl();           // ا
$result->patternSurface(); // اها
```

---

Analyze a Poem
--------------

[](#analyze-a-poem)

```
$analysis = QafyaDetector::make()->analyze([
    'قفْ بالديار وصحْ إلى بيداها',
    'فعسى الديار تجيبُ منْ ناداها',
]);

$analysis->status();             // ok|review|partial|error
$analysis->rawi();               // ه
$analysis->qafyaPattern();       // اها
$analysis->hasMultipleQafyas();  // false
$analysis->clusters();
$analysis->endings();
```

---

Laravel
-------

[](#laravel)

```
use Mosab\QafyaDetector\Laravel\Facades\QafyaDetector;

$result = QafyaDetector::extract('كتابُهُ');
$analysis = QafyaDetector::analyze($poem);
```

Publish config:

```
php artisan vendor:publish --tag=mosab-qafya-detector-config
```

---

API
---

[](#api)

```
QafyaDetector::make()->extract(string $text, array|QafyaOptions $options = []): QafyaResult
QafyaDetector::make()->extractArray(string $text, array|QafyaOptions $options = []): array

QafyaDetector::make()->analyze(string|array $poem, array|QafyaOptions $options = []): PoemQafyaAnalysis
QafyaDetector::make()->analyzeArray(string|array $poem, array|QafyaOptions $options = []): array
```

---

Poem-Level Policy
-----------------

[](#poem-level-policy)

The public poem-level qafya identity is based on **rawi**.

- `radf`, `wasl`, `khurooj`, `taasis`, `dakhiil`, and harakat are preserved in details.
- They may produce defects or sanad warnings.
- They do not automatically mean that the poem has multiple qafyas.

The package separates:

- `dominant`: reliable public qafya when authoritative.
- `indexing`: most frequent rawi/cluster for search and filtering.
- `clusters`: grouped rawi-level results.
- `endings`: every analyzed ending.

---

Quality
-------

[](#quality)

```
composer validate --strict
vendor/bin/pint --test
vendor/bin/phpstan analyse src
vendor/bin/pest
php benchmarks/basic.php
```

---

Documentation
-------------

[](#documentation)

- [Arabic documentation](docs/ar.md)
- [English documentation](docs/en.md)

---

Known Limitations
-----------------

[](#known-limitations)

Arabic qafya often needs context. Undiacritized poetry, ambiguous final haa, extra noon forms, and multi-section poems may require human review. The package exposes `status`, `defects`, `sanad`, `clusters`, and `endings` so applications can decide whether a result is authoritative or needs review.

---

Why the package is named Mosab
------------------------------

[](#why-the-package-is-named-mosab)

The name **Mosab** was chosen because it carries a direct poetic and historical meaning in Arabic culture.

In Arabic, **مُصعب** suggests strength, firmness, and the ability to handle difficult matters. This fits the package because Arabic qafya detection is not a simple “last-letter” problem. It requires dealing with complex endings, ambiguous letters, weak letters, haa, radf, wasl, khurooj, taasis, dakhiil, and poem-level context.

The name also echoes the spirit of classical Arabic poetry: concise, strong, and rooted in Arabic language heritage.

So the package name reflects its purpose:

- **Strong enough** to handle difficult Arabic qafya cases.
- **Arabic in identity**, not a generic NLP name.
- **Short and memorable** for a PHP package.
- **Suitable for open source**, while still connected to Arabic poetry and language.

In short, **Mosab Qafya Detector** means a serious Arabic-first tool built to handle one of the most difficult parts of Arabic poetry analysis: the qafya.

لماذا اخترنا اسم مصعب للحزمة؟
-----------------------------

[](#لماذا-اخترنا-اسم-مصعب-للحزمة)

اخترنا اسم **مُصعب** لأنه اسم عربي قصير، واضح، وله إيحاء مناسب لطبيعة الحزمة.

فالقافية العربية ليست مسألة سهلة يمكن حلّها بالنظر إلى آخر حرف فقط. تحليل القافية يحتاج التعامل مع حالات دقيقة مثل: الروي، الردف، الوصل، الخروج، التأسيس، الدخيل، الهاء، حروف العلة، والألف المقصورة، مع مراعاة سياق القصيدة لا الكلمة وحدها.

واسم **مُصعب** في العربية يوحي بالقوة والصلابة والقدرة على معالجة الأمور الصعبة، وهذا يناسب هدف الحزمة: بناء أداة عربية جادة تستطيع التعامل مع صعوبة القافية لا تبسيطها تبسيطًا مخلًا.

كما أن الاسم يحمل طابعًا عربيًا أصيلًا، ويبتعد عن الأسماء التقنية العامة، ليبقى قريبًا من مجال الشعر واللغة العربية.

باختصار، اسم **Mosab Qafya Detector** يعني:

- أداة عربية الهوية.
- مخصصة لمشكلة دقيقة وصعبة في الشعر العربي.
- قصيرة وسهلة التذكر كاسم حزمة.
- مناسبة لمشروع مفتوح المصدر يخدم مطوري الشعر العربي والباحثين في القافية.

لذلك كان اسم **مُصعب** اختيارًا مناسبًا لحزمة تهدف إلى تحليل واحد من أصعب أبواب الشعر العربي: **القافية**.

Source:
-------

[](#source)

This package started as part of the core qafya analysis work behind [موسوعة الشعراء](https://poetspedia.com), then became open source to help Arabic poetry developers, researchers, and linguists.

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance84

Actively maintained with recent releases

Popularity6

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

82d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7a7658e6b20d82e76e6b4ae5da38a4dd759f2d3053993a5180617171c777f399?d=identicon)[helturkey](/maintainers/helturkey)

---

Tags

laravelarabicpoetryrhymeqafyaarud

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/helturkey-mosab-qafya-detector/health.svg)

```
[![Health](https://phpackages.com/badges/helturkey-mosab-qafya-detector/health.svg)](https://phpackages.com/packages/helturkey-mosab-qafya-detector)
```

###  Alternatives

[yemenifree/laravel-arabic-numbers-middleware

auto transforms arabic/eastern to eastern/arabic numbers for i.e ١٢٣٤٥٦٧٨ to 12345678

18135.7k](/packages/yemenifree-laravel-arabic-numbers-middleware)[stephenjude/filament-blog

Filament Blog Builder

20619.4k](/packages/stephenjude-filament-blog)[still-code/ar-php-laravel

ar-php-laravel

398.5k](/packages/still-code-ar-php-laravel)[maherelgamil/arabicdatetime

Easy and useful tool to generate arabic or hijri date with multi-language support for laravel

414.6k](/packages/maherelgamil-arabicdatetime)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
