2022-12-26 06:42:01 +01:00
|
|
|
## About
|
2022-04-26 14:12:16 +02:00
|
|
|
|
2023-01-04 04:55:54 +01:00
|
|
|
This repository contains the holy book, The Quran, in its original Arabic
|
|
|
|
and as translations in English, Farsi, and Portuguese. The contents are made
|
|
|
|
available in the JSON, and SQL formats.
|
2022-12-26 06:42:01 +01:00
|
|
|
|
|
|
|
**Contents**
|
2022-04-26 14:12:16 +02:00
|
|
|
|
2022-07-12 19:57:37 +02:00
|
|
|
1. [`src/json/`directory](#srcjson-directory)
|
|
|
|
2. [`src/sql/` directory](#srcsql-directory)
|
2022-07-11 23:08:58 +02:00
|
|
|
3. [`bin/` directory](#bin-directory)
|
|
|
|
|
2022-12-26 06:42:01 +01:00
|
|
|
## <a id='srcjson-directory'>`src/json/` directory</a>
|
2022-04-26 14:12:16 +02:00
|
|
|
|
2022-12-26 20:29:58 +01:00
|
|
|
* The [src/json/ar/](src/json/ar/) directory contains The Quran in its original Arabic.
|
2022-06-20 18:37:22 +02:00
|
|
|
|
2022-12-26 20:29:58 +01:00
|
|
|
* The [src/json/en/](src/json/en/) directory contains an English translation of The Quran.
|
2022-06-20 18:37:22 +02:00
|
|
|
|
2022-12-26 20:29:58 +01:00
|
|
|
* The [src/json/fa/](src/json/fa/) directory contains a Farsi translation of The Quran.
|
2022-06-20 18:37:22 +02:00
|
|
|
|
2022-12-26 20:29:58 +01:00
|
|
|
* The [src/json/pt/](src/json/pt/) directory contains a Portuguese translation of The Quran.
|
2022-04-26 21:34:37 +02:00
|
|
|
|
2022-10-07 01:12:02 +02:00
|
|
|
* The [src/json/chapter-metadata.json](src/json/chapter-metadata.json) file
|
2022-12-26 20:29:58 +01:00
|
|
|
contains information about each chapter in The Quran.
|
2022-06-09 07:26:26 +02:00
|
|
|
|
2022-12-26 06:42:01 +01:00
|
|
|
### File structure
|
2022-08-11 15:56:28 +02:00
|
|
|
|
2022-10-07 01:12:02 +02:00
|
|
|
Each JSON file represents a chapter, or surah. For example -
|
|
|
|
[src/json/ar/1.json](src/json/ar/1.json) contains Al-Fatihah. The structure of the JSON
|
|
|
|
files can be described as an array where the first element is an object that contains
|
|
|
|
information aboout the chapter, and the rest of the array is composed of two-element arrays -
|
|
|
|
the first element being the verse number, and the second element being the contents of
|
|
|
|
the verse. For example:
|
2022-04-26 14:12:16 +02:00
|
|
|
|
|
|
|
```
|
|
|
|
[
|
2022-10-06 14:13:00 +02:00
|
|
|
{ <chapter metadata> },
|
2022-04-26 14:12:16 +02:00
|
|
|
[
|
|
|
|
<verse number>,
|
|
|
|
<verse contents>
|
|
|
|
],
|
|
|
|
[
|
|
|
|
<verse number>,
|
|
|
|
<verse contents>
|
|
|
|
],
|
|
|
|
[
|
|
|
|
<verse number>,
|
|
|
|
<verse contents>
|
|
|
|
],
|
|
|
|
/* etc... */
|
|
|
|
]
|
|
|
|
```
|
|
|
|
|
2022-12-26 06:42:01 +01:00
|
|
|
### Chapter metadata
|
2022-10-07 01:12:02 +02:00
|
|
|
|
|
|
|
* [src/json/chapter-metadata.json](/src/json/chapter-metadata.json) <br>
|
|
|
|
[Source: https://quran.com](https://quran.com)
|
|
|
|
|
|
|
|
The [src/json/chapter-metadata.json](/src/json/chapter-metadata.json) file contains
|
2022-12-26 20:29:58 +01:00
|
|
|
information about each chapter in The Quran. The JSON file is structured as an array
|
2022-10-07 01:12:02 +02:00
|
|
|
of objects, where each object describes a given chapter.
|
|
|
|
|
|
|
|
The following example demonstrates how Al-Fatihah is described. The "codepoints"
|
2022-12-26 20:33:31 +01:00
|
|
|
property is a sequence of unicode codepoints representing a surah's name in Arabic.
|
|
|
|
The codepoints can be mapped to Arabic using JavaScript's
|
|
|
|
`String.fromCodePoint(...codepoints)` function.
|
2022-10-07 01:12:02 +02:00
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"id": "1",
|
|
|
|
"place_of_revelation": "makkah",
|
|
|
|
"transliterated_name": "Al-Fatihah",
|
|
|
|
"translated_name": "The Opener",
|
|
|
|
"verse_count": 7,
|
|
|
|
"slug": "al-fatihah",
|
|
|
|
"codepoints": [
|
|
|
|
1575,
|
|
|
|
1604,
|
|
|
|
1601,
|
|
|
|
1575,
|
|
|
|
1578,
|
|
|
|
1581,
|
|
|
|
1577
|
|
|
|
]
|
|
|
|
},
|
|
|
|
```
|
|
|
|
|
2022-12-26 06:42:01 +01:00
|
|
|
## <a id='srcsql-directory'>`src/sql/` directory</a>
|
2022-07-10 23:04:06 +02:00
|
|
|
|
|
|
|
* The [src/sql/schema.sql](src/sql/schema.sql) defines the schema of the database. <br>
|
|
|
|
The schema is composed of three tables: `qurans`, `chapters`, and `verses`.
|
|
|
|
|
|
|
|
* The [src/sql/seed.sql](src/sql/seed.sql) populates the contents of the database. <br>
|
|
|
|
The languages included are Arabic, English, Farsi, and Portuguese.
|
|
|
|
|
2023-01-04 04:55:54 +01:00
|
|
|
* The [src/sql/queries/](src/sql/queries) directory contains `.sql` files that
|
|
|
|
contain example SQL queries.
|
2022-08-16 04:54:05 +02:00
|
|
|
|
2022-12-26 06:42:01 +01:00
|
|
|
### SQLite3
|
2022-07-10 23:04:06 +02:00
|
|
|
|
2023-01-04 04:55:54 +01:00
|
|
|
The SQL files mentioned above can be used to create a fully populated database
|
|
|
|
in-memory and on disk using SQLite3. Other SQL databases might work as well but
|
|
|
|
have not been tested.
|
2022-07-10 23:04:06 +02:00
|
|
|
|
|
|
|
**1. $HOME/.sqliterc**
|
|
|
|
|
2023-01-04 04:55:54 +01:00
|
|
|
For identical results - it is recommended that `$HOME/.sqliterc` has the
|
|
|
|
following contents:
|
2022-07-10 23:04:06 +02:00
|
|
|
|
|
|
|
```
|
2022-06-04 19:09:42 +02:00
|
|
|
PRAGMA case_sensitive_like=ON;
|
2022-07-10 23:04:06 +02:00
|
|
|
pragma FOREIGN_KEYS = on;
|
|
|
|
.headers on
|
|
|
|
.mode column
|
2022-06-04 19:09:42 +02:00
|
|
|
|
2022-07-10 23:04:06 +02:00
|
|
|
```
|
|
|
|
|
2023-01-04 04:55:54 +01:00
|
|
|
**2. Save the database to disk**
|
2022-07-10 23:04:06 +02:00
|
|
|
|
2023-01-04 04:55:54 +01:00
|
|
|
The `.save` command can be used to save the database to disk:
|
2022-07-10 23:04:06 +02:00
|
|
|
|
2022-05-28 08:54:34 +02:00
|
|
|
```
|
|
|
|
sqlite> .read src/sql/schema.sql
|
|
|
|
sqlite> .read src/sql/seed.sql
|
|
|
|
sqlite> .save src/sql/quran.db
|
|
|
|
sqlite> .exit
|
2022-07-10 23:04:06 +02:00
|
|
|
```
|
|
|
|
|
2023-01-04 04:55:54 +01:00
|
|
|
SQLite3 can then be started with the path to the database that's been saved
|
|
|
|
to disk:
|
2022-07-10 23:04:06 +02:00
|
|
|
|
|
|
|
```
|
2022-05-28 08:54:34 +02:00
|
|
|
$ sqlite3 src/sql/quran.db
|
|
|
|
sqlite> SELECT qurans.id FROM qurans WHERE qurans.locale = 'ar';
|
|
|
|
id
|
|
|
|
--
|
|
|
|
1
|
|
|
|
sqlite>
|
2022-07-11 23:16:56 +02:00
|
|
|
```
|
2022-07-11 23:16:07 +02:00
|
|
|
|
2022-10-06 14:13:00 +02:00
|
|
|
**3. Query the database**
|
2022-07-11 23:26:55 +02:00
|
|
|
|
2022-10-06 14:13:00 +02:00
|
|
|
3.1
|
2022-05-28 08:54:34 +02:00
|
|
|
|
2023-01-04 04:55:54 +01:00
|
|
|
The SQL query we will execute fetches the contents of chapter 112 in
|
|
|
|
the English locale (i.e: `en`):
|
2022-07-11 23:26:55 +02:00
|
|
|
|
|
|
|
```sql
|
|
|
|
SELECT qurans.locale,
|
2022-05-28 02:57:57 +02:00
|
|
|
chapters.tr_name AS "chapter (name)",
|
|
|
|
chapters.number AS chapter,
|
|
|
|
verses.number AS verse,
|
2022-05-28 08:54:34 +02:00
|
|
|
verses.content
|
|
|
|
FROM verses
|
|
|
|
INNER JOIN qurans
|
|
|
|
ON qurans.id = verses.quran_id
|
|
|
|
INNER JOIN chapters
|
|
|
|
ON chapters.id = verses.chapter_id
|
|
|
|
WHERE qurans.locale = "en"
|
|
|
|
AND chapters.number = 112;
|
2022-07-11 23:26:55 +02:00
|
|
|
```
|
|
|
|
|
2023-01-04 04:55:54 +01:00
|
|
|
The output should look similar to this:
|
2022-07-11 23:26:55 +02:00
|
|
|
|
|
|
|
```
|
2022-05-28 08:54:34 +02:00
|
|
|
locale chapter (name) chapter verse content
|
|
|
|
------ -------------- ------- ----- -----------------------------------------------------
|
|
|
|
en Al-Ikhlas 112 1 Say, ˹O Prophet,˺ “He is Allah—One ˹and Indivisible˺;
|
|
|
|
en Al-Ikhlas 112 2 Allah—the Sustainer ˹needed by all˺.
|
|
|
|
en Al-Ikhlas 112 3 He has never had offspring, nor was He born.
|
|
|
|
en Al-Ikhlas 112 4 And there is none comparable to Him.”
|
2022-07-11 23:26:55 +02:00
|
|
|
```
|
2022-07-10 23:04:06 +02:00
|
|
|
|
2022-10-06 14:13:00 +02:00
|
|
|
3.2
|
2022-07-18 01:12:54 +02:00
|
|
|
|
2023-01-04 04:55:54 +01:00
|
|
|
The next query we will find a particular phrase in the English translation of The Quran
|
|
|
|
by using the LIKE operator:
|
2022-05-28 08:54:34 +02:00
|
|
|
|
|
|
|
```sql
|
|
|
|
SELECT qurans.locale,
|
|
|
|
chapters.name AS "chapter (name)",
|
|
|
|
chapters.number AS chapter,
|
|
|
|
verses.number AS verse,
|
|
|
|
verses.content
|
|
|
|
FROM verses
|
|
|
|
INNER JOIN qurans
|
|
|
|
ON qurans.id = verses.quran_id
|
|
|
|
INNER JOIN chapters
|
|
|
|
ON chapters.id = verses.chapter_id
|
|
|
|
WHERE qurans.locale = "en"
|
|
|
|
AND verses.content LIKE "%reflected light%";
|
2022-07-18 01:12:54 +02:00
|
|
|
|
|
|
|
```
|
|
|
|
|
2023-01-04 04:55:54 +01:00
|
|
|
The output should look similar to this:
|
2022-07-18 01:12:54 +02:00
|
|
|
|
|
|
|
```
|
2022-05-28 08:54:34 +02:00
|
|
|
locale chapter (name) chapter verse content
|
2022-05-28 02:57:57 +02:00
|
|
|
------ -------------- ------- ----- ----------------------------------------------------
|
|
|
|
en Jonah 10 5 He is the One Who made the sun a radiant source and
|
|
|
|
the moon a reflected light, with precisely ordained
|
|
|
|
phases, so that you may know the number of years and
|
|
|
|
calculation ˹of time˺. Allah did not create all this
|
|
|
|
except for a purpose. He makes the signs clear for
|
|
|
|
people of knowledge.
|
2022-07-18 01:12:54 +02:00
|
|
|
```
|
|
|
|
|
2022-05-28 08:54:34 +02:00
|
|
|
|
2022-12-26 06:42:01 +01:00
|
|
|
## <a id='bin-directory'>`bin/` directory</a>
|
2022-04-26 21:34:37 +02:00
|
|
|
|
2022-07-10 23:04:06 +02:00
|
|
|
The [bin/](bin/) directory contains scripts that generate the
|
2022-04-26 21:34:37 +02:00
|
|
|
contents of the [src/](src/) directory:
|
|
|
|
|
2022-07-14 01:14:19 +02:00
|
|
|
* JSON scripts
|
|
|
|
|
|
|
|
* [bin/json/pull-arabic](bin/json/pull-arabic) <br>
|
2022-07-10 23:04:06 +02:00
|
|
|
This script is responsible for populating [src/json/ar/](src/json/ar/).
|
2022-04-26 21:34:37 +02:00
|
|
|
|
2022-07-14 01:14:19 +02:00
|
|
|
* [bin/json/pull-english](bin/json/pull-english) <br>
|
2022-07-10 23:04:06 +02:00
|
|
|
This script is responsible for populating [src/json/en/](src/json/en/).
|
2022-04-26 21:34:37 +02:00
|
|
|
|
2022-07-14 01:14:19 +02:00
|
|
|
* [bin/json/pull-farsi](bin/json/pull-farsi) <br>
|
2022-07-10 23:04:06 +02:00
|
|
|
This script is responsible for populating [src/json/fa/](src/json/fa/).
|
2022-06-17 10:37:57 +02:00
|
|
|
|
2022-07-14 01:14:19 +02:00
|
|
|
* [bin/json/pull-portuguese](bin/json/pull-portuguese) <br>
|
2022-07-10 23:04:06 +02:00
|
|
|
This script is responsible for populating [src/json/pt/](src/json/pt/).
|
|
|
|
|
2022-10-06 13:36:43 +02:00
|
|
|
* [bin/json/pull-chapter-metadata](bin/json/pull-chapter-metadata) <br>
|
|
|
|
The script is responsible for generating [src/json/chapter-metadata.json](src/json/chapter-metadata.json).
|
|
|
|
|
2022-10-06 14:13:00 +02:00
|
|
|
* [bin/json/insert-chapter-metadata](bin/json/insert-chapter-data) <br>
|
|
|
|
This script is responsible for inserting chapter metadata as the first element
|
|
|
|
of a JSON array that otherwise contains the contents of a chapter
|
|
|
|
(eg [src/json/ar/1.json](src/json/ar/1.json), ...).
|
|
|
|
|
2022-07-14 01:14:19 +02:00
|
|
|
* SQL scripts
|
|
|
|
|
|
|
|
* [bin/sql/create-sql-seed-file](bin/sql/create-sql-seed-file) <br>
|
2022-07-17 22:17:26 +02:00
|
|
|
This script creates [src/sql/seed.sql](src/sql/seed.sql) - using the contents of [src/json/](src/json/).
|
2022-06-19 00:13:03 +02:00
|
|
|
|
2022-12-26 06:42:01 +01:00
|
|
|
**Notes**
|
2022-07-10 23:04:06 +02:00
|
|
|
|
2022-12-26 06:42:01 +01:00
|
|
|
* It is not neccessary to run the scripts mentioned above. <br>
|
|
|
|
The content they create is included in `src/` already.
|
2022-04-26 21:34:37 +02:00
|
|
|
|
2022-12-26 06:42:01 +01:00
|
|
|
* The scripts are written in [Ruby v3.1.0+](https://www.ruby-lang.org). <br>
|
|
|
|
The script dependencies can be installed by running the following from
|
|
|
|
the root of the repository:
|
2022-07-17 21:58:34 +02:00
|
|
|
|
|
|
|
```
|
2022-07-19 21:54:10 +02:00
|
|
|
gem install bundler --no-document
|
2022-07-17 21:58:34 +02:00
|
|
|
bundle install
|
|
|
|
```
|
|
|
|
|
2022-04-27 01:57:03 +02:00
|
|
|
## Download
|
|
|
|
|
2023-01-04 04:55:54 +01:00
|
|
|
The contents of the repository is provided as a zip file.
|
|
|
|
<br>
|
|
|
|
[Download zip file](https://github.com/ReflectedLight/The-Qur-an/archive/refs/tags/v0.11.1.zip).
|
2022-04-27 01:57:03 +02:00
|
|
|
|
2022-07-14 01:18:37 +02:00
|
|
|
## Credit, and thanks
|
2022-04-26 14:12:16 +02:00
|
|
|
|
2022-04-26 22:07:25 +02:00
|
|
|
The content of the [src/](src/) directory was automatically generated
|
2022-04-26 21:34:37 +02:00
|
|
|
thanks to the following websites:
|
2022-04-26 14:12:16 +02:00
|
|
|
|
2022-12-26 06:42:01 +01:00
|
|
|
* https://searchtruth.com - for the original Arabic.
|
2022-04-26 21:34:37 +02:00
|
|
|
* https://quran.com - for the English translation.
|
2022-06-19 00:13:03 +02:00
|
|
|
* https://al-quran.cc - for the Farsi, and Portuguese translations.
|
2022-05-29 19:27:59 +02:00
|
|
|
|
2022-07-14 01:18:37 +02:00
|
|
|
## License
|
2022-05-29 19:27:59 +02:00
|
|
|
|
2022-06-17 10:37:57 +02:00
|
|
|
This software is released into the Public Domain.
|
2022-07-19 21:54:10 +02:00
|
|
|
|