PyArud (بَيَارُوض)
PyArud is a deterministic, high-performance, zero-dependency Python engine for Arabic Prosody (علم العروض والقافية). It provides mathematically sound meter identification across all 16 classical Arabic meters (البحور الستة عشر) and their sub-meter variations (التام، المجزوء، المشطور، المنهوك، المخلع), foot-by-foot phonetic scansion, exact Zihaf & 'Ilah diagnosis, and rhyme (القافية) analysis.
✨ Features
- 🚀 Zero External Dependencies: 100% pure Python standard library. Completely independent from
pyarabicor any heavy external packages. - ⚡ Extreme Throughput:
- Phonetic Arudi Conversion: >22,000 hemistichs/second ($0.045\text{ ms/op}$)
- Full Multi-Meter Verse Scansion: >3,000 verses/second ($0.325\text{ ms/op}$)
- 🎯 100% Deterministic Disambiguation: Formal metric grammar engine resolving notoriously tricky classical overlaps (e.g. Kamel vs Rajaz, Wafer vs Hazaj, Mukhalla' al-Basit, Saree, and single-shatr meters).
- 🎼 Full 16-Meter Coverage: Comprehensive support for all 16 Farahidian meters and variations (Tam, Majzoo, Mashtoor, Manhook, Mukhalla').
- 🔬 Granular Foot Scansion: Precise foot-by-foot status (
ok,broken,missing,extra_bits), identifying exact Zihafat (القبض، الخبن، الطي، الكف، العصب، الإضمار، الخبل، الشكل) and 'Ilal (القطع، القصر، الحذف، التذييل، التسبيغ، الكسف، الوقف). - 📜 Complete Qafiyah Analysis: Identifies Rawi (الروي), Wasl (الوصل), Khuruj (الخروج), Ridf (الردف), Ta'sees (التأسيس), and classical rhyme movement classifications (المقيدة والمطلقة).
- 🛡️ 100% Type Safe & Modern: Strict type annotations with
mypyand modern Python dataclass models.
🚀 Installation
Requires Python 3.10+.
pip install pyarud
⚡ Quick Start
from pyarud import ArudhProcessor
processor = ArudhProcessor()
# 1. Analyze a classical verse (Sadr & Ajuz)
verse = ("أَخِي جَاوَزَ الظَّالِمُونَ الْمَدَى", "فَحَقَّ الْجِهَادُ وَحَقَّ الْفِدَا")
analysis = processor.analyze_verse(*verse)
print(f"Meter: {analysis.meter_name_ar} ({analysis.meter_key})")
print(f"Score: {analysis.score}")
print(f"Arudi Pattern: {analysis.sadr.pattern} | {analysis.ajuz.pattern}")
# Foot-by-foot breakdown
for foot in analysis.sadr.feet:
print(f" [{foot.status.upper()}] {foot.tafeela_name_ar} ({foot.pattern}) - {foot.zihaf_name_ar}")
# Rhyme (Qafiyah)
if analysis.qafiyah:
print(f"Rawi: {analysis.qafiyah.rawi_char}")
Analyzing Complete Poems
verses = [
("قِفَا نَبْكِ مِنْ ذِكْرَى حَبِيبٍ وَمَنْزِلِ", "بِسِقْطِ اللِّوَى بَيْنَ الدَّخُولِ فَحَوْمَلِ"),
("فَتُوضِحَ فَالْمِقْرَاةِ لَمْ يَعْفُ رَسْمُهَا", "لِمَا نَسَجَتْهَا مِنْ جَنُوبٍ وَشَمْأَلِ"),
]
poem_report = processor.analyze_poem(verses)
print(f"Global Meter: {poem_report.meter_name_ar}")
print(f"Dominant Rawi: {poem_report.dominant_rawi}")
print(f"Average Confidence: {poem_report.average_score:.2%}")
📊 Benchmark & Accuracy
Benchmarked on 25 authentic classical poems (76 verses) across all 16 meters from Al-Diwan:
| Metric | Result |
|---|---|
| Classification Accuracy (16 Buhur) | 100.0% (76 / 76 verses) |
| Phonetic Conversion Speed | 22,101 hemistichs / sec |
| Verse Analysis Speed | 3,078 verses / sec |
| External Runtime Dependencies | 0 (Zero) |
🛠️ Testing & Development
# Clone repository
git clone https://github.com/cnemri/pyarud.git
cd pyarud
# Run complete test suite (63 unit & benchmark tests)
uv run pytest
# Check code formatting & types
uv run ruff check .
uv run mypy pyarud
📄 License
This project is licensed under the MIT License.
Metadata
Release files for pyarud 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| pyarud-1.0.0.tar.gz | 116.7 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyarud-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 169.0 kB
Release files / pyarud-1.0.0.tar.gz
| Download URL | pyarud-1.0.0.tar.gz |
|---|---|
| Size | 116.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0a12c8f81003fb0b43e59803886a9d5d5c7b95b006005220836a5602958038c2
|
|
BLAKE2b-256 checksum How to use checksums |
47cd7d6d5b13e3b154791990c8e26c31d64dd98d097135fb2e2e82ea8895540a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / pyarud-1.0.0-py3-none-any.whl
| Download URL | pyarud-1.0.0-py3-none-any.whl |
|---|---|
| Size | 52.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
03d5fb11850065fe5a5eb4b5b6fe6a63102975f902b7c9273f606151591e832e
|
|
BLAKE2b-256 checksum How to use checksums |
4ae045eeba532c960defcbc3ea027562b797a122fa3acd1ed14803754d546ebc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Security for pyarud 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.