I built a deterministic engine to analyze 8th-century Arabic Poetry meters (Arud) with Python
Posted by chou404@reddit | Python | View on Reddit | 3 comments
Hi everyone,
I’ve just released PyArud v0.1.3, a Python library that digitizes the science of Arabic Prosody (ilm al-Arudh), originally founded by Al-Khalil bin Ahmed in the 8th century.
What My Project Does
Arabic poetry is built on a binary system of "Moving" (Mutaharrik) and "Still" (Sakin) sounds, forming 16 distinct meters (Buhur). Analyzing this computationally is hard because:
- Orthography vs. Phonetics: What is written isn't what is pronounced (e.g., "Allahu" has a hidden long vowel).
- Complexity: A single meter like Kamil has dozens of valid variations (Zihaf) where letters can be dropped or quieted.
- LLMs struggle: Asking ChatGPT to scan a poem usually results in hallucinations because it predicts tokens rather than strictly following the prosodic rules.
The Solution: PyArud
I built a deterministic engine that:
* Converts Text: Uses regex and lookaheads to handle deep phonetic rules (like Iltiqa al-Sakinayn - the meeting of two stills).
* Greedy Matching: Implements a greedy algorithm to segment verses into their component feet (Tafilas).
* Deep Analysis: Identifies not just the meter, but the specific defect (Ellah) used in every foot.
Example
from pyarud.processor import ArudhProcessor
# A verse from Al-Mutanabbi
verse = [("أَلا لا أُري الأحْداثَ حَمْدًا وَلا ذَمّا", "فَما بَطْشُها جَهْلًا وَلا كَفُّها حِلْما")]
processor = ArudhProcessor()
result = processor.process_poem(verse)
print(f"Meter: {result['meter']}") # Output: 'taweel'
print(f"Score: {result['verses'][0]['score']}") # Output: 1.0
Target Audience
Developers building apps for arabic poetry
Comparison:
No alternative solutions exist for this problem
What's new in v0.1.3?
* Robustness: Improved handling of "Solar Lam" and implicit vowels.
* Architecture: A modular pipeline separating linguistic normalization from mathematical pattern matching.
Links
* Repo: https://github.com/cnemri/pyarud
* Docs: https://cnemri.github.io/pyarud
* PyPI: `pip install pyarud`
t_spray05@reddit
https://discord.gg/F7H36DTE https://www.linkedin.com/in/akshatpant3/
Love your passion!! ♥️
I think I have something for you. I'm working on a tool. I'm looking to collab with a simple/advanced software/data engineer, but is passionate to build something soon.
I have been work 4-6 hrs a day (besides my full time job)
I'm designing an unseemingly connected Behavioral Algo tool.
ammar_sadaoui@reddit
as someone who claims he is native Arabic, know that the system exists before
thanks 😊
Scypio@reddit
This is awesome. I understood nothing of it, but this is the kind of project I always loved about Python - somebody taking their passion and moving it to another level. Awesome stuff!
This is to ease the pronunciation of the verse? Or to help with rhythm and cadence of reciting?