Metadata-Version: 2.4
Name: quran-text
Version: 0.1.0
Summary: Read the quran-text dataset: the Qurʾān in seven riwāyāt with pages, lines, āyāt, waqf marks and one shared word numbering. Ḥafṣ bundled.
Author-email: quran-ws <service@quran.ws>
License: CC-BY-4.0
Project-URL: Homepage, https://quran.ws
Project-URL: Repository, https://github.com/quran-ws/quran-text
Project-URL: Issues, https://github.com/quran-ws/quran-text/issues
Keywords: quran,mushaf,hafs,warsh,qalun,riwayahs,arabic,rasm_uthmani
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Text Processing :: Linguistic
Classifier: Natural Language :: Arabic
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# quran-text for Python

No dependencies, Python 3.9+. Ḥafṣ is bundled. Copy `quran_text.py` and
`quran_text_data/` into your project, or `pip install` this directory.

```python
from quran_text import Mushaf, AyahMap

m = Mushaf.hafs()                                    # bundled Ḥafṣ
m.ayah(2, 255).text                                  # plain words
m.ayah(2, 255).render(marks=True, ayah_marks=True) # with waqf marks and ۝٢٥٥
m.page(3).render(marks=True, ayah_marks=True, lines=True)
m.surah(112).ayahs                                     # [Ayah(112:1), …]
m.juz(30).first_ayah.key                             # "78:1"
m.word(1, 4, 1).number                               # 11, the same word in every riwāyah
m.sajdat()                                           # every āyah printed with ۩
m.search("مالك يوم الدين")                           # [Span(10, 13)]

w = Mushaf.load("data/mushaf/warsh.json")            # another riwāyah
AyahMap.load("data/ayah-map.json").convert(2, 255, "warsh")   # MappedAyah(2, 253, 'split', 254)
```

The font the text needs is bundled too: `m.font.family` names it and `m.font.path`
is the `.ttf`. For another riwāyah `Mushaf.load(path)` finds its font beside
`data/fonts/`.

Wrong numbers raise `IndexError`; a layer the file lacks (juz in Bazzī) raises
`KeyError` with the reason from the file. The full API is in
[`../README.md`](../README.md).

Test: `python3 -m unittest lib/python/test_quran_text.py` from the repo root.
