Skip to main content

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.

PyPI License Python 3.10+ Zero Dependencies


✨ Features

  • 🚀 Zero External Dependencies: 100% pure Python standard library. Completely independent from pyarabic or 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 mypy and 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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyarud-1.0.0.tar.gz (116.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyarud-1.0.0-py3-none-any.whl (52.3 kB view details)

Uploaded Python 3

File details

Details for the file pyarud-1.0.0.tar.gz.

File metadata

  • Download URL: pyarud-1.0.0.tar.gz
  • Upload date:
  • Size: 116.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pyarud-1.0.0.tar.gz
Algorithm Hash digest
SHA256 0a12c8f81003fb0b43e59803886a9d5d5c7b95b006005220836a5602958038c2
MD5 c843d0323b74818fc75d3617b648d980
BLAKE2b-256 47cd7d6d5b13e3b154791990c8e26c31d64dd98d097135fb2e2e82ea8895540a

See more details on using hashes here.

File details

Details for the file pyarud-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: pyarud-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 52.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pyarud-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 03d5fb11850065fe5a5eb4b5b6fe6a63102975f902b7c9273f606151591e832e
MD5 a5168dba7d714a65c58946fb173d1f43
BLAKE2b-256 4ae045eeba532c960defcbc3ea027562b797a122fa3acd1ed14803754d546ebc

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 files

0.1.10

2 files

0.1.9

2 files

0.1.8

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page