quran-processing-toolkit 0.4.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. quran_processing_toolkit-0.4.0/CHANGELOG.md +46 -0
  2. quran_processing_toolkit-0.4.0/CONTRIBUTING.md +125 -0
  3. quran_processing_toolkit-0.4.0/LICENSE +201 -0
  4. quran_processing_toolkit-0.4.0/MANIFEST.in +12 -0
  5. quran_processing_toolkit-0.4.0/PKG-INFO +269 -0
  6. quran_processing_toolkit-0.4.0/README.md +228 -0
  7. quran_processing_toolkit-0.4.0/THIRD_PARTY_NOTICES.md +22 -0
  8. quran_processing_toolkit-0.4.0/docs/AI_GUIDE.md +146 -0
  9. quran_processing_toolkit-0.4.0/docs/API_REFERENCE.md +430 -0
  10. quran_processing_toolkit-0.4.0/docs/ARCHITECTURE.md +207 -0
  11. quran_processing_toolkit-0.4.0/docs/CLI.md +128 -0
  12. quran_processing_toolkit-0.4.0/docs/DATA_MODEL.md +177 -0
  13. quran_processing_toolkit-0.4.0/docs/DATA_PROVENANCE.md +86 -0
  14. quran_processing_toolkit-0.4.0/docs/GETTING_STARTED.md +212 -0
  15. quran_processing_toolkit-0.4.0/docs/MORPHOLOGY.md +225 -0
  16. quran_processing_toolkit-0.4.0/docs/PROPOSED_CORPUS_CHANGES.md +44 -0
  17. quran_processing_toolkit-0.4.0/docs/QUERY_COOKBOOK.md +294 -0
  18. quran_processing_toolkit-0.4.0/docs/README.md +25 -0
  19. quran_processing_toolkit-0.4.0/docs/RELEASING.md +102 -0
  20. quran_processing_toolkit-0.4.0/docs/ROADMAP.md +136 -0
  21. quran_processing_toolkit-0.4.0/docs/TRANSLATIONS.md +230 -0
  22. quran_processing_toolkit-0.4.0/examples/compare_verse_endings.py +17 -0
  23. quran_processing_toolkit-0.4.0/examples/export_verb_index.py +96 -0
  24. quran_processing_toolkit-0.4.0/examples/first_person_plural_only.py +13 -0
  25. quran_processing_toolkit-0.4.0/examples/inspect_annotation.py +18 -0
  26. quran_processing_toolkit-0.4.0/examples/longest_without_mim_or_nun.py +12 -0
  27. quran_processing_toolkit-0.4.0/examples/noun_morphology.py +14 -0
  28. quran_processing_toolkit-0.4.0/examples/present_verb_forms.py +9 -0
  29. quran_processing_toolkit-0.4.0/examples/search_and_scope.py +15 -0
  30. quran_processing_toolkit-0.4.0/examples/use_user_translation.py +12 -0
  31. quran_processing_toolkit-0.4.0/examples/verse_word_frequency.py +74 -0
  32. quran_processing_toolkit-0.4.0/examples/weak_letter_roots.py +10 -0
  33. quran_processing_toolkit-0.4.0/licenses/TANZIL-METADATA-NOTICE.txt +15 -0
  34. quran_processing_toolkit-0.4.0/llms.txt +30 -0
  35. quran_processing_toolkit-0.4.0/pyproject.toml +66 -0
  36. quran_processing_toolkit-0.4.0/quran_processing_toolkit/__init__.py +96 -0
  37. quran_processing_toolkit-0.4.0/quran_processing_toolkit/__main__.py +3 -0
  38. quran_processing_toolkit-0.4.0/quran_processing_toolkit/build.py +263 -0
  39. quran_processing_toolkit-0.4.0/quran_processing_toolkit/chapter_names.py +142 -0
  40. quran_processing_toolkit-0.4.0/quran_processing_toolkit/cli.py +95 -0
  41. quran_processing_toolkit-0.4.0/quran_processing_toolkit/collections.py +615 -0
  42. quran_processing_toolkit-0.4.0/quran_processing_toolkit/corpus.py +611 -0
  43. quran_processing_toolkit-0.4.0/quran_processing_toolkit/models.py +672 -0
  44. quran_processing_toolkit-0.4.0/quran_processing_toolkit/py.typed +1 -0
  45. quran_processing_toolkit-0.4.0/quran_processing_toolkit/similarity.py +98 -0
  46. quran_processing_toolkit-0.4.0/quran_processing_toolkit/source_data.py +201 -0
  47. quran_processing_toolkit-0.4.0/quran_processing_toolkit/text.py +259 -0
  48. quran_processing_toolkit-0.4.0/quran_processing_toolkit/translations.py +313 -0
  49. quran_processing_toolkit-0.4.0/quran_processing_toolkit/validation.py +73 -0
  50. quran_processing_toolkit-0.4.0/quran_processing_toolkit.egg-info/PKG-INFO +269 -0
  51. quran_processing_toolkit-0.4.0/quran_processing_toolkit.egg-info/SOURCES.txt +65 -0
  52. quran_processing_toolkit-0.4.0/quran_processing_toolkit.egg-info/dependency_links.txt +1 -0
  53. quran_processing_toolkit-0.4.0/quran_processing_toolkit.egg-info/entry_points.txt +3 -0
  54. quran_processing_toolkit-0.4.0/quran_processing_toolkit.egg-info/requires.txt +13 -0
  55. quran_processing_toolkit-0.4.0/quran_processing_toolkit.egg-info/top_level.txt +1 -0
  56. quran_processing_toolkit-0.4.0/requirements.txt +2 -0
  57. quran_processing_toolkit-0.4.0/setup.cfg +4 -0
  58. quran_processing_toolkit-0.4.0/tests/fixtures/translation-sample.txt +2 -0
  59. quran_processing_toolkit-0.4.0/tests/test_corpus.py +70 -0
  60. quran_processing_toolkit-0.4.0/tests/test_documentation.py +64 -0
  61. quran_processing_toolkit-0.4.0/tests/test_queries.py +147 -0
  62. quran_processing_toolkit-0.4.0/tests/test_rebuild.py +53 -0
  63. quran_processing_toolkit-0.4.0/tests/test_similarity.py +124 -0
  64. quran_processing_toolkit-0.4.0/tests/test_translations.py +207 -0
  65. quran_processing_toolkit-0.4.0/tests/test_verb_helpers.py +236 -0
  66. quran_processing_toolkit-0.4.0/tools.py +37 -0
  67. quran_processing_toolkit-0.4.0/verses_per_juzz.py +13 -0
@@ -0,0 +1,46 @@
1
+ # Changelog
2
+
3
+ ## 0.4.0 — 2026-11-12
4
+
5
+ First release of `quran-processing-toolkit` on production PyPI, paired with
6
+ `quran-processing-toolkit-qac-data==0.4.0`. Earlier versions were development and
7
+ TestPyPI previews. This release is early-stage; future minor releases may introduce
8
+ changes documented here.
9
+
10
+ ### Included
11
+
12
+ - Typed corpus model: 114 chapters, 6,236 verses, 77,429 QAC-aligned words,
13
+ 128,219 morphology tokens, and 30 juz divisions.
14
+ - Quranic 1-based address lookup and composable immutable query results.
15
+ - Arabic and ASCII Buckwalter text search with explicit normalization.
16
+ - Token and word morphology filters, grouping, counts, root/lemma sets, and
17
+ nun-of-emphasis detection tied to the annotated verb stem.
18
+ - Cached part-of-speech token selections, including proper nouns, pronouns,
19
+ adjectives, adverbs, prepositions, conjunctions, nominals, and particles.
20
+ - Arabic, ASCII, and English chapter names with attributed metadata.
21
+ - Exact pairwise surface-word comparison for a one-word addition, substitution,
22
+ or shift, with an explicit pause-mark policy.
23
+ - Optional local TXT/JSON translation layers with provenance and coverage checks;
24
+ explicit pinned download/cache support for Qara'i from Tanzil.
25
+ - CLI commands for stats, search, word inspection, sources, validation, and
26
+ deterministic morphology rebuilds.
27
+ - Source hash verification and a reproducible derived-record cache outside the
28
+ installed packages. No translation is bundled or downloaded implicitly.
29
+ - Task-oriented documentation, an AI usage guide, `llms.txt`, and runnable examples.
30
+
31
+ ### Migration from the 0.3.0 TestPyPI preview
32
+
33
+ The old `quran.verbs` and `quran.nouns` properties selected whole words. Rename
34
+ these to `quran.verb_words` and `quran.noun_words` to preserve that behavior.
35
+ Use `quran.verbs()` and `quran.nouns()` for individual morphological tokens.
36
+
37
+ On a token, `form` / `get_form()` is surface spelling; `verb_form` is the
38
+ morphological Roman numeral. Query `with_form("IV")` selects the morphological form.
39
+ Word-level `get_form()` retains its morphological meaning. Use token queries when
40
+ all chained conditions must match a single stem in a multi-stem word.
41
+
42
+ ### Source-data distribution 0.4.0
43
+
44
+ Packages the verbatim QAC morphology 0.4 and Tanzil Uthmani text 1.1, a juz-boundary
45
+ table, an integrity manifest, and complete source-specific license notices.
46
+ See [Data provenance](docs/DATA_PROVENANCE.md) for exact hashes and terms.
@@ -0,0 +1,125 @@
1
+ # Contributing
2
+
3
+ Contributions are welcome, particularly readable query helpers, documentation, tests,
4
+ performance improvements with measured benefit, and source-preserving morphology
5
+ interpretations.
6
+
7
+ ## Non-negotiable data rule
8
+
9
+ Do not edit Quranic text, morphology records, tags, roots, lemmas, or other material
10
+ annotations in place.
11
+
12
+ If an upstream record appears wrong:
13
+
14
+ 1. record the exact address and source feature text;
15
+ 2. explain the linguistic evidence;
16
+ 3. propose either a documented runtime interpretation or an upstream report;
17
+ 4. add a focused test; and
18
+ 5. obtain explicit project approval before changing any semantic overlay.
19
+
20
+ Verbatim third-party source files must remain byte-identical to their declared hashes.
21
+ Any accepted transformation change must increment `TRANSFORMATION_VERSION`, update the
22
+ canonical derived digest, and be documented in
23
+ [`docs/PROPOSED_CORPUS_CHANGES.md`](docs/PROPOSED_CORPUS_CHANGES.md).
24
+
25
+ ## Development setup
26
+
27
+ ```bash
28
+ python -m venv .venv
29
+ . .venv/bin/activate
30
+ python -m pip install -e packages/quran_processing_toolkit_qac_data
31
+ python -m pip install -e ".[dev]"
32
+ ```
33
+
34
+ On Windows PowerShell, activate with `.venv\Scripts\Activate.ps1`.
35
+
36
+ ## Required checks
37
+
38
+ ```bash
39
+ ruff check .
40
+ ruff format --check .
41
+ mypy quran_processing_toolkit packages/quran_processing_toolkit_qac_data/src
42
+ python -m unittest discover -s tests -v
43
+ python -m quran_processing_toolkit.build --check
44
+ python -m quran_processing_toolkit validate
45
+ ```
46
+
47
+ Also run every relevant script in `examples/`. CI repeats checks across supported
48
+ Python versions, builds both distributions, runs `twine check`, and smoke-installs the
49
+ wheels outside the checkout.
50
+
51
+ ## API design principles
52
+
53
+ Good additions make a family of questions easier rather than encoding one answer.
54
+
55
+ Prefer:
56
+
57
+ - `starts_with(prefix)` over `starts_with_alif()`;
58
+ - `with_number("plural")` over `first_person_plural_verbs()`;
59
+ - `in_verse(chapter, verse)` over a helper named after one famous verse; and
60
+ - composable immutable results over functions that print immediately.
61
+
62
+ Named helpers are valuable when they remove routine lambdas or knowledge of internal
63
+ uppercase fields. They should delegate to the generic query machinery where practical
64
+ so named and advanced queries behave consistently.
65
+
66
+ Public text input should remain ASCII-friendly through Buckwalter. New categorical
67
+ arguments should normally be case-insensitive and accept obvious source abbreviations.
68
+ Roots, lemmas, surface forms, and raw features remain case-sensitive because character
69
+ case may be meaningful.
70
+
71
+ ## Documentation expectations
72
+
73
+ Any public API change should update:
74
+
75
+ - its Python docstring;
76
+ - [`docs/API_REFERENCE.md`](docs/API_REFERENCE.md);
77
+ - the relevant conceptual guide or cookbook example; and
78
+ - tests demonstrating expected behavior and failure cases.
79
+
80
+ Comments should explain invariants, source mismatches, or non-obvious decisions—not
81
+ translate straightforward Python line by line.
82
+
83
+ ## Testing guidance
84
+
85
+ - Use canonical addresses for focused regression tests.
86
+ - Assert source fields and derived fields separately.
87
+ - Include multi-stem behavior when an aggregation API changes.
88
+ - Test both Arabic and Buckwalter for text operations.
89
+ - Test aliases and canonical categorical values.
90
+ - Avoid copying copyrighted translation text into fixtures; authored placeholder text
91
+ is sufficient.
92
+ - Never weaken source hash or derived digest verification to make a test pass.
93
+
94
+ ## Performance changes
95
+
96
+ Measure at least:
97
+
98
+ - a fresh uncached process load;
99
+ - a derived-disk-cache process load;
100
+ - a repeated in-process `load_quran()` call; and
101
+ - the target query on the complete corpus.
102
+
103
+ Report Python version, platform, command, and whether `orjson` was installed. Avoid
104
+ performance changes that discard source traceability, alter public ordering, or turn
105
+ simple imports into mandatory compiled dependencies.
106
+
107
+ ## Compatibility
108
+
109
+ The public package supports Python 3.10 and newer. Preserve:
110
+
111
+ - Quranic 1-based semantic indexing;
112
+ - normal zero-based positions inside filtered QuerySets;
113
+ - deterministic corpus order;
114
+ - source-feature visibility;
115
+ - the separate code/data distribution boundary; and
116
+ - user-installed rather than bundled translation files.
117
+
118
+ Deprecated compatibility aliases may remain when inexpensive, but new documentation
119
+ should teach the clearest current API.
120
+
121
+ ## Releases
122
+
123
+ Core and data distributions have independent versions and tags. Do not publish either
124
+ manually with a long-lived token. Follow [`docs/RELEASING.md`](docs/RELEASING.md),
125
+ publishing the data distribution before a core release whose `data` extra pins it.
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,12 @@
1
+ include LICENSE
2
+ include README.md
3
+ include CONTRIBUTING.md
4
+ include requirements.txt
5
+ include tools.py
6
+ include verses_per_juzz.py
7
+ recursive-include docs *.md
8
+ recursive-include examples *.py
9
+ recursive-include tests *.py *.txt
10
+ include THIRD_PARTY_NOTICES.md
11
+ include CHANGELOG.md
12
+ include llms.txt
@@ -0,0 +1,269 @@
1
+ Metadata-Version: 2.4
2
+ Name: quran-processing-toolkit
3
+ Version: 0.4.0
4
+ Summary: Natural, queryable access to Quranic text and morphology
5
+ Author: Maysum Panju
6
+ License-Expression: Apache-2.0 AND LicenseRef-Tanzil-Metadata-CC-BY
7
+ Project-URL: Homepage, https://github.com/mhpanju/QuranProcessingToolkit
8
+ Project-URL: Documentation, https://github.com/mhpanju/QuranProcessingToolkit/blob/master/docs/README.md
9
+ Project-URL: Repository, https://github.com/mhpanju/QuranProcessingToolkit
10
+ Project-URL: Issues, https://github.com/mhpanju/QuranProcessingToolkit/issues
11
+ Project-URL: Changelog, https://github.com/mhpanju/QuranProcessingToolkit/blob/master/CHANGELOG.md
12
+ Keywords: quran,arabic,corpus,morphology,linguistics,buckwalter
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Intended Audience :: Education
16
+ Classifier: Intended Audience :: Science/Research
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3 :: Only
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Programming Language :: Python :: 3.14
24
+ Classifier: Topic :: Text Processing :: Linguistic
25
+ Classifier: Typing :: Typed
26
+ Requires-Python: >=3.10
27
+ Description-Content-Type: text/markdown
28
+ License-File: LICENSE
29
+ License-File: licenses/TANZIL-METADATA-NOTICE.txt
30
+ Provides-Extra: fast
31
+ Requires-Dist: orjson>=3.10; extra == "fast"
32
+ Provides-Extra: data
33
+ Requires-Dist: quran-processing-toolkit-qac-data==0.4.0; extra == "data"
34
+ Provides-Extra: dev
35
+ Requires-Dist: build>=1.2; extra == "dev"
36
+ Requires-Dist: mypy>=1.17; extra == "dev"
37
+ Requires-Dist: pytest>=8; extra == "dev"
38
+ Requires-Dist: ruff>=0.12; extra == "dev"
39
+ Requires-Dist: twine>=6; extra == "dev"
40
+ Dynamic: license-file
41
+
42
+ # Quran Processing Toolkit
43
+
44
+ Typed Python access to Quranic text, morphology, and composable research queries.
45
+ Search in Arabic or ASCII Buckwalter, inspect every original annotation, and address
46
+ chapters, verses, words, and tokens using Quranic 1-based indexes.
47
+
48
+ Requires **Python 3.10+**. Version **0.4.0** is the first production PyPI release;
49
+ the API is early-stage and future minor releases may introduce documented changes.
50
+
51
+ ## Install and run
52
+
53
+ ```bash
54
+ python -m pip install "quran-processing-toolkit[data]"
55
+ ```
56
+
57
+ ```python
58
+ from quran_processing_toolkit import load_quran
59
+
60
+ quran = load_quran()
61
+ assert len(quran.chapters) == 114
62
+ assert len(quran.verses) == 6236
63
+
64
+ print(quran.chapter(2).name) # al-Baqarah
65
+ print(quran.verse(2, 255).get_arabic())
66
+
67
+ # ASCII search input is Buckwalter, so an Arabic keyboard is optional.
68
+ quran.search("muwsaY").show("arabic", limit=3)
69
+
70
+ # These are verb tokens: all filters apply to the same morphological stem.
71
+ present = quran.verbs().with_tense("present")
72
+ print(present.most_common_forms(limit=5))
73
+
74
+ quran.verses.ends_with("n", strip_diacritics=True).show("arabic", limit=3)
75
+ ```
76
+
77
+ Loading is offline and verifies the installed source data. Nothing is downloaded
78
+ implicitly. The core has no mandatory third-party Python dependencies. Code and data
79
+ are separate distributions because their licenses differ; the `data` extra installs
80
+ the matching source-data package. For optional faster cache decoding, install
81
+ `"quran-processing-toolkit[data,fast]"`.
82
+
83
+ ## What you can do
84
+
85
+ | Task | API | Guide |
86
+ |---|---|---|
87
+ | Look up an address | `quran.verse(2, 255)` | [Getting started](https://github.com/mhpanju/QuranProcessingToolkit/blob/master/docs/GETTING_STARTED.md) |
88
+ | Search Arabic or Buckwalter | `quran.search("muwsaY")` | [Query cookbook](https://github.com/mhpanju/QuranProcessingToolkit/blob/master/docs/QUERY_COOKBOOK.md) |
89
+ | Filter stems by root, form, tense, voice, person, or number | `quran.verbs().with_root("qwl")` | [Morphology](https://github.com/mhpanju/QuranProcessingToolkit/blob/master/docs/MORPHOLOGY.md) |
90
+ | Select nouns, pronouns, particles, and other parts of speech | `quran.nouns()`, `quran.pronouns()` | [API reference](https://github.com/mhpanju/QuranProcessingToolkit/blob/master/docs/API_REFERENCE.md) |
91
+ | Count, group, and export results | `results.count_by("root")`, `results.select("address")` | [Cookbook](https://github.com/mhpanju/QuranProcessingToolkit/blob/master/docs/QUERY_COOKBOOK.md) |
92
+ | Compare two verses for one-word edits | `compare_verses(a, b)` | [Comparison API](https://github.com/mhpanju/QuranProcessingToolkit/blob/master/docs/API_REFERENCE.md#chapter-names-and-surface-word-comparison) |
93
+ | Add a local translation or explicitly download one | `load_translation()`, `download_translation()` | [Translations](https://github.com/mhpanju/QuranProcessingToolkit/blob/master/docs/TRANSLATIONS.md) |
94
+ | Inspect sources and validate the corpus | `quran.provenance()`, `quran-toolkit validate` | [Data provenance](https://github.com/mhpanju/QuranProcessingToolkit/blob/master/docs/DATA_PROVENANCE.md) |
95
+
96
+ SQL and a database server are not required. Named helpers cover ordinary queries;
97
+ `where()`, `filter()`, `group_by()`, and `count_by()` support custom analyses.
98
+
99
+ ## Addresses, words, and tokens
100
+
101
+ ```python
102
+ chapter = quran.chapters[1]
103
+ verse = quran.verses[2, 255]
104
+ word = quran.words[2, 255, 1]
105
+ token = quran.tokens[2, 255, 1, 1]
106
+ juz = quran.juzs[1]
107
+
108
+ results = quran.verbs().in_chapter(2)
109
+ first_result = results[0] # filtered results use ordinary zero-based positions
110
+ ```
111
+
112
+ A **word** is a QAC-aligned orthographic word. A **token** is one morphological
113
+ segment: prefixes, stems, and suffixes can be separate tokens inside a word.
114
+ `quran.verbs()` and `quran.nouns()` return tokens; `quran.verb_words` and
115
+ `quran.noun_words` return whole words. Chained word filters aggregate stem values,
116
+ so use token queries when all conditions must match a single stem.
117
+
118
+ On a token, `form` is its surface spelling and `verb_form` is its Roman-numeral
119
+ morphological form. The query `with_form("IV")` selects the morphological form.
120
+ Roots and lemmas use case-sensitive Buckwalter; categorical aliases such as
121
+ `"present"`, `"IMPF"`, `"passive"`, and `"PASS"` are accepted by the relevant helpers.
122
+
123
+ See [Data model and indexing](https://github.com/mhpanju/QuranProcessingToolkit/blob/master/docs/DATA_MODEL.md)
124
+ for multi-stem behavior and the full hierarchy.
125
+
126
+ ## Compose research queries
127
+
128
+ ```python
129
+ # Roots found in first-person plural verbs but never first-person singular verbs.
130
+ plural = quran.verbs().with_person(1).with_number("plural")
131
+ singular = quran.verbs().with_person(1).with_number("singular")
132
+ plural_only_roots = plural.roots() - singular.roots()
133
+
134
+ # Three-letter noun roots with at least two weak letters.
135
+ weak_roots = quran.nouns().with_root_length(3).with_minimum_root_letter_count("Awy", 2)
136
+
137
+ # Explicit nun-of-emphasis annotations associated with their verb stem.
138
+ emphatic = quran.verbs().with_nun_of_emphasis()
139
+ assert len(emphatic) == 243
140
+
141
+ # The longest within-verse word run containing neither mim nor nun.
142
+ longest = quran.longest_word_sequence_without_letters("mn", strip_diacritics=True)
143
+
144
+ # Preserve access to every original annotation.
145
+ token = quran.token(2, 38, 6, 1)
146
+ print(token.source_feature_text)
147
+ print(token.source_features)
148
+ ```
149
+
150
+ Text matching is literal by default. ASCII input selects Buckwalter; non-ASCII
151
+ input selects Arabic. Pass normalization options explicitly, for example
152
+ `strip_diacritics=True`, `strip_quranic_marks=True`, or `normalize_alif=True`.
153
+ Use `representation="translation"` for translation search so English input is
154
+ not interpreted as Buckwalter.
155
+
156
+ ## Translations and verse comparison
157
+
158
+ Translations are optional. Load your own UTF-8 `chapter|verse|text` file or supported
159
+ JSON file:
160
+
161
+ ```python
162
+ translated = load_quran(translation="/path/to/translation.txt")
163
+ print(translated.verse(1, 1).get_translation())
164
+ ```
165
+
166
+ An explicit, hash-verified downloader is also available:
167
+
168
+ ```python
169
+ from quran_processing_toolkit import compare_verses, download_translation
170
+
171
+ # This call opts into a network download on first use.
172
+ translated = load_quran(translation=download_translation("en.qarai"))
173
+ translated.require_translation() # require coverage of all 6,236 verses
174
+
175
+ changes = compare_verses(
176
+ quran.verse(27, 68),
177
+ quran.verse(23, 83),
178
+ ignore_pause_marks=True,
179
+ )
180
+ for change in changes:
181
+ print(change.kind, change.verse_a.address, change.verse_b.address)
182
+ ```
183
+
184
+ The catalog currently contains Ali Quli Qarai's English translation from Tanzil.
185
+ Its terms specify non-commercial use unless permission is obtained from the
186
+ translator or publisher. Downloads are cached outside the package and support
187
+ `offline=True`. Missing translation output raises `TranslationNotAvailableError`.
188
+ See [Translations](https://github.com/mhpanju/QuranProcessingToolkit/blob/master/docs/TRANSLATIONS.md)
189
+ for terms, formats, coverage checks, and provenance.
190
+
191
+ `compare_verses()` explains a single-word addition, substitution, or shift between
192
+ two verses. It returns zero or one match, rather than a general similarity score.
193
+ Its space-delimited surface positions differ from QAC word addresses; it performs
194
+ no spelling or vowel normalization.
195
+
196
+ ## Command line
197
+
198
+ ```bash
199
+ quran-toolkit stats
200
+ quran-toolkit search muwsaY --level verse --limit 5
201
+ quran-toolkit word 2:255:1
202
+ quran-toolkit sources
203
+ quran-toolkit validate
204
+ quran-rebuild --check
205
+ ```
206
+
207
+ The [CLI reference](https://github.com/mhpanju/QuranProcessingToolkit/blob/master/docs/CLI.md)
208
+ explains all commands, options, and exit behavior.
209
+
210
+ ## Integrity and caching
211
+
212
+ Every newly constructed corpus verifies source filenames, sizes, and SHA-256 hashes,
213
+ plus the canonical derived morphology digest. Later equivalent `load_quran()` calls
214
+ reuse the same in-process object. A local derived JSON cache speeds up new processes;
215
+ installed source files are never changed.
216
+
217
+ ```python
218
+ fresh = load_quran(cache=False) # a new object graph
219
+ uncached = load_quran(cache=False, disk_cache=False) # rederive from source
220
+ ```
221
+
222
+ Set `QURAN_PROCESSING_TOOLKIT_CACHE` or pass `cache_dir=...` to relocate the derived
223
+ cache. Read-only cache locations fall back to uncached loading. See
224
+ [Architecture](https://github.com/mhpanju/QuranProcessingToolkit/blob/master/docs/ARCHITECTURE.md).
225
+
226
+ ## Documentation for people and AI assistants
227
+
228
+ Start at the [documentation index](https://github.com/mhpanju/QuranProcessingToolkit/blob/master/docs/README.md).
229
+ The [AI usage guide](https://github.com/mhpanju/QuranProcessingToolkit/blob/master/docs/AI_GUIDE.md)
230
+ provides a compact, executable introduction, task-to-API mapping, and common mistakes.
231
+ [`llms.txt`](https://github.com/mhpanju/QuranProcessingToolkit/blob/master/llms.txt)
232
+ links to the authoritative Markdown references.
233
+
234
+ - [Getting started](https://github.com/mhpanju/QuranProcessingToolkit/blob/master/docs/GETTING_STARTED.md)
235
+ - [Query cookbook](https://github.com/mhpanju/QuranProcessingToolkit/blob/master/docs/QUERY_COOKBOOK.md)
236
+ - [API reference](https://github.com/mhpanju/QuranProcessingToolkit/blob/master/docs/API_REFERENCE.md)
237
+ - [Morphology reference](https://github.com/mhpanju/QuranProcessingToolkit/blob/master/docs/MORPHOLOGY.md)
238
+ - [Release notes and preview migration](https://github.com/mhpanju/QuranProcessingToolkit/blob/master/CHANGELOG.md)
239
+ - [Runnable examples](https://github.com/mhpanju/QuranProcessingToolkit/tree/master/examples), including a [complete verb JSON exporter](https://github.com/mhpanju/QuranProcessingToolkit/blob/master/examples/export_verb_index.py)
240
+ - [Known limits and roadmap](https://github.com/mhpanju/QuranProcessingToolkit/blob/master/docs/ROADMAP.md)
241
+ - [Contributing](https://github.com/mhpanju/QuranProcessingToolkit/blob/master/CONTRIBUTING.md)
242
+
243
+ ## Development
244
+
245
+ ```bash
246
+ python -m venv .venv
247
+ . .venv/bin/activate
248
+ python -m pip install -e packages/quran_processing_toolkit_qac_data
249
+ python -m pip install -e ".[dev]"
250
+ ruff check .
251
+ ruff format --check .
252
+ mypy quran_processing_toolkit packages/quran_processing_toolkit_qac_data/src
253
+ python -m unittest discover -s tests -v
254
+ python -m quran_processing_toolkit.build --check
255
+ python -m quran_processing_toolkit validate
256
+ ```
257
+
258
+ The historical `from tools import QuranCorpus` import is available in source
259
+ checkouts. Installed applications should import `quran_processing_toolkit`.
260
+
261
+ ## License and attribution
262
+
263
+ The Python code is Apache-2.0. The core also includes separately attributed Tanzil
264
+ chapter-label metadata, whose upstream declaration is CC-BY without a version;
265
+ see [Third-party notices](https://github.com/mhpanju/QuranProcessingToolkit/blob/master/THIRD_PARTY_NOTICES.md).
266
+ The data package preserves the QAC and Tanzil sources verbatim under their respective
267
+ upstream terms, with full notices. No translation is bundled. Read
268
+ [Data provenance and licensing](https://github.com/mhpanju/QuranProcessingToolkit/blob/master/docs/DATA_PROVENANCE.md)
269
+ before redistributing data or derived artifacts.