Skip to main content

A query-first Python toolkit for Quranic text, morphology, translations, tafsir, and pattern discovery.

Project description

QuranKit

QuranKit is a query-first Python toolkit for computational Quran analysis, providing structured access to Quranic text, morphology, roots, lemmas, translations, tafsir, and linguistic pattern discovery.

Developed by Dr. Faisal Alshargi.


Features

  • Quranic verse retrieval
  • Root-based search
  • Lemma-based search
  • Word-level linguistic analysis
  • POS tagging access
  • Morphological feature access
  • Multi-language translations
  • Tafsir retrieval
  • Root-order pattern discovery
  • Frequency analysis
  • Research-oriented querying
  • Memory-only dataset loading

Design Philosophy

QuranKit is designed around feature-level access rather than dataset export.

Users interact with the Quran through focused search and analysis functions instead of downloading or manipulating the complete dataset.

Core Principles

  • Returns only the requested information
  • Compact results by default
  • No API key required
  • No remote inference
  • Query-first architecture
  • Memory-only dataset loading
  • Translation and tafsir access only when explicitly requested

QuranKit intentionally does not provide:

q.to_dataframe()
q.export_json()
q.export_dataset()
q.dump_all()

This keeps the package focused on analysis, exploration, and research rather than dataset replication.


Installation

pip install qurankit

For development:

pip install -e .

Quick Start

from qurankit import QuranKit

q = QuranKit()

print(q.stats())

ayah = q.get_ayah(1, 1)
print(ayah)

results = q.search_root("رحم", limit=3)

translation = q.get_translation(2, 255, lang="en")
print(translation["translation"])

Statistics

q.stats()

Example:

{
    "surahs": 114,
    "ayahs": 6236,
    "languages": 20,
    "roots": 1600,
    "lemmas": 14000
}

Verse Retrieval

q.get_ayah(1, 1)

Example output:

{
    "sura": 1,
    "ayah": 1,
    "sura_ar": "الفاتحة",
    "sura_en": "Al-Fātiḥah",
    "ayatext_nt": "بسم الله الرحمن الرحيم"
}

Linguistic Features

Retrieve individual linguistic layers without loading unnecessary information.

q.get_words(2, 255)

q.get_roots(2, 255)

q.get_lemmas(2, 255)

q.get_pos(2, 255)

q.get_morph_tags(2, 255)

q.get_analysis(2, 255)

q.word_analysis(2, 255)

Search

Search Text

q.search_text("الله", limit=5)

Search Word

q.search_word("جنة", limit=5)

Search Root

q.search_root("رحم", limit=5)

Search Lemma

q.search_lemma("ٱللَّه", limit=5)

Search POS Tags

q.search_pos("V", limit=5)

Search results remain compact and exclude long translations and tafsir content.


Translations

List available languages:

q.available_languages()

Retrieve a specific translation:

q.get_translation(2, 255, lang="en")

Retrieve multiple translations:

q.get_translations(
    1,
    1,
    langs=["en", "tr", "de"]
)

Search inside translations:

q.search_translation(
    "mercy",
    lang="en",
    limit=5
)

Tafsir

Retrieve tafsir only when requested.

Al-Muyassar

q.get_tafsir(
    1,
    1,
    source="muyassar"
)

Al-Jalalayn

q.get_tafsir(
    1,
    1,
    source="jalalayn"
)

Pattern Discovery

Repeated root-order patterns:

q.find_repeated_root_orders(
    min_occurrences=2,
    limit=10
)

Root frequency statistics:

q.root_frequency(limit=20)

Random Verse

q.random_ayah()

Dataset Handling

QuranKit ships with a minimal bundled sample dataset for testing and fallback purposes.

The complete Quran dataset is loaded from the internal default dataset source into memory only.

QuranKit does not intentionally persist the full dataset to local storage and does not provide dataset export utilities.


Performance

import time

start = time.time()

q = QuranKit()

print(
    "Load time:",
    round(time.time() - start, 2),
    "seconds"
)

Example Research Workflow

from qurankit import QuranKit

q = QuranKit()

verses = q.search_root("رحم", limit=10)

for verse in verses:
    print(
        verse["sura"],
        verse["ayah"],
        verse["ayatext_nt"]
    )

Disclaimer

QuranKit is intended for computational analysis, research, education, and software development.

It is not a source of religious rulings, legal opinions, or authoritative tafsir.

Project details


Download files

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

Source Distribution

qurankit-0.4.0.tar.gz (19.2 kB view details)

Uploaded Source

Built Distribution

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

qurankit-0.4.0-py3-none-any.whl (17.9 kB view details)

Uploaded Python 3

File details

Details for the file qurankit-0.4.0.tar.gz.

File metadata

  • Download URL: qurankit-0.4.0.tar.gz
  • Upload date:
  • Size: 19.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for qurankit-0.4.0.tar.gz
Algorithm Hash digest
SHA256 4541ca7172f78118b523b8df93ebe28dfd36fb410134a74f30e717b23b4537aa
MD5 de57c90447f3385344ce58599405a21e
BLAKE2b-256 5d99fdb66af50d5e615beafe73dffcf9f18d465f8221937713cebbadc24051de

See more details on using hashes here.

File details

Details for the file qurankit-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: qurankit-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 17.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for qurankit-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 66ceab57a150d6d96023448218e11ac8291ef5ca2e0b688a9f78d613b86b1eac
MD5 a37a49c33125a4fe34c20eba98e0fdbe
BLAKE2b-256 acb62810ad0dfd565dc9accb44fec4614aaf62c2f6ecc9ee898b35269c691978

See more details on using hashes here.

Supported by

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