Skip to content

Commit 795ce22

Browse files
committed
add docs
1 parent ded3f21 commit 795ce22

File tree

11 files changed

+244
-22
lines changed

11 files changed

+244
-22
lines changed

Manifest.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,9 @@ version = "0.12.11"
174174

175175
[[deps.Compat]]
176176
deps = ["TOML", "UUIDs"]
177-
git-tree-sha1 = "0037835448781bb46feb39866934e243886d756a"
177+
git-tree-sha1 = "9d8a54ce4b17aa5bdce0ea5c34bc5e7c340d16ad"
178178
uuid = "34da2185-b29b-5c13-b0c7-acf172513d20"
179-
version = "4.18.0"
179+
version = "4.18.1"
180180
weakdeps = ["Dates", "LinearAlgebra"]
181181

182182
[deps.Compat.extensions]
@@ -242,9 +242,9 @@ version = "1.11.0"
242242

243243
[[deps.Distributions]]
244244
deps = ["AliasTables", "FillArrays", "LinearAlgebra", "PDMats", "Printf", "QuadGK", "Random", "SpecialFunctions", "Statistics", "StatsAPI", "StatsBase", "StatsFuns"]
245-
git-tree-sha1 = "3e6d038b77f22791b8e3472b7c633acea1ecac06"
245+
git-tree-sha1 = "3bc002af51045ca3b47d2e1787d6ce02e68b943a"
246246
uuid = "31c24e10-a181-5473-b8eb-7969acd0382f"
247-
version = "0.25.120"
247+
version = "0.25.122"
248248

249249
[deps.Distributions.extensions]
250250
DistributionsChainRulesCoreExt = "ChainRulesCore"
@@ -845,9 +845,9 @@ version = "0.8.5+0"
845845

846846
[[deps.OpenSSL_jll]]
847847
deps = ["Artifacts", "JLLWrappers", "Libdl"]
848-
git-tree-sha1 = "2ae7d4ddec2e13ad3bddf5c0796f7547cf682391"
848+
git-tree-sha1 = "f19301ae653233bc88b1810ae908194f07f8db9d"
849849
uuid = "458c3c95-2e84-50aa-8efc-19380b2a3a95"
850-
version = "3.5.2+0"
850+
version = "3.5.4+0"
851851

852852
[[deps.OpenSpecFun_jll]]
853853
deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl"]

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "Yunir"
22
uuid = "6ba116df-6904-454d-b214-90038a8281a6"
33
authors = ["Al-Ahmadgaid B. Asaad"]
4-
version = "0.3.0"
4+
version = "0.2.8"
55

66
[deps]
77
BioAlignments = "00701ae9-d1dc-5365-b64a-a3a3ebf5695e"

docs/Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
66
DocumenterCitations = "daee34ce-89f3-4625-b898-19384cb65244"
77
Kitab = "56988f64-bbe1-4670-be0e-9b8570beea21"
88
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
9+
QuranTree = "f647ab69-6f05-4d64-883f-59d0fbe08d2b"
910
Yunir = "6ba116df-6904-454d-b214-90038a8281a6"

docs/make.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
using Pkg
2+
Pkg.develop(PackageSpec(path=dirname(@__DIR__)))
3+
Pkg.instantiate()
4+
15
using Documenter
26
using DocumenterCitations
37
using Yunir
@@ -19,7 +23,7 @@ makedocs(;
1923
"Home" => "index.md",
2024
"Basic Utilities" => "man/basic_utilities.md",
2125
"Orthographical Analysis" => "man/orthography.md",
22-
"Text Alignment" => "man/text_alignment.md",
26+
# "Text Alignment" => "man/text_alignment.md",
2327
"Rhytmic Analysis" => "man/rhythmic_analysis.md",
2428
"Symmetry Analysis" => "man/symmetry_analysis.md",
2529
"References" => "man/references.md",

docs/src/man/basic_utilities.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ Basic Utilities
33
In this section, we are going to discuss how to use the APIs for dediacritization, normalization, and transliteration.
44
## Dediacritization
55
The function to use is `dediac` which works on either Arabic, Buckwalter or custom transliterated characters.
6-
```@setup abc
7-
using Yunir
8-
@transliterator :default
9-
```
106
```@repl abc
117
using Yunir
128

docs/src/man/rhythmic_analysis.md

Lines changed: 83 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,90 @@
11
Rhythmic Analysis
22
=============
3-
Pre-Islamic civilization in Arabia is known for their expertise in poetry prior to Qur'an. Such prevalence in Arabic language may invoke some interest in studying the rhythmic signatures of these texts. There are no resources that looked into this computationally until the recent work of [asaadthesis](@citet).
3+
The prevalence of poetry in Arabic literature necessitates scientific tool to study the rhythmic signatures. Unfortunately, there are no resources for such methodology until the recent work of [asaadthesis](@citet). This section will demonstrate the APIs for doing rhythmic analysis based on the methodologies proposed by [asaadthesis](@citet). To do this, there are two types of text that will be studied, and these are pre-Islamic poetry and the Holy Qur'an.
44

5-
## Classic Poetry
6-
Thi
5+
## Arabic Poetry
6+
The first data is from a well known author, [Al-Mutanabbi المتنبّي](https://en.wikipedia.org/wiki/Al-Mutanabbi), who authored several poetry including the titled [*'Indeed, every woman with a swaying walk'*](https://www.youtube.com/watch?v=9c1IrQwfYFM), which will be the basis for this section.
7+
## Loading Data
8+
The following codes assigns the said poem of Al-Mutanabbi to a variable poem.
9+
```@example abc
10+
using Yunir
711
8-
### References
12+
poem = """
13+
ألا كُلُّ مَاشِيَةِ الخَيْزَلَى ;
14+
فِدَى كلِّ ماشِيَةِ الهَيْذَبَى;
15+
وَكُلِّ نَجَاةٍ بُجَاوِيَّةٍ;
16+
خَنُوفٍ وَمَا بيَ حُسنُ المِشَى;
17+
وَلَكِنّهُنّ حِبَالُ الحَيَاةِ;
18+
وَكَيدُ العُداةِ وَمَيْطُ الأذَى;
19+
ضرَبْتُ بهَا التّيهَ ضَرْبَ القِمَا;
20+
رِ إمّا لهَذا وَإمّا لِذا;
21+
إذا فَزِعَتْ قَدّمَتْهَا الجِيَادُ;
22+
وَبِيضُ السّيُوفِ وَسُمْرُ القَنَا;
23+
فَمَرّتْ بِنَخْلٍ وَفي رَكْبِهَا;
24+
عَنِ العَالَمِينَ وَعَنْهُ غِنَى;
25+
وَأمْسَتْ تُخَيّرُنَا بِالنّقا;
26+
بِ وَادي المِيَاهِ وَوَادي القُرَى;
27+
وَقُلْنَا لهَا أينَ أرْضُ العِراقِ;
28+
فَقَالَتْ وَنحنُ بِتُرْبَانَ هَا;
29+
وَهَبّتْ بِحِسْمَى هُبُوبَ الدَّبُو;
30+
رِ مُستَقْبِلاتٍ مَهَبَّ الصَّبَا;
31+
رَوَامي الكِفَافِ وَكِبْدِ الوِهَادِ;
32+
وَجَارِ البُوَيْرَةِ وَادي الغَضَى;
33+
وَجَابَتْ بُسَيْطَةَ جَوْبَ الرِّدَا;
34+
ءِ بَينَ النّعَامِ وَبَينَ المَهَا;
35+
إلى عُقْدَةِ الجَوْفِ حتى شَفَتْ;
36+
بمَاءِ الجُرَاوِيّ بَعضَ الصّدَى;
37+
وَلاحَ لهَا صَوَرٌ وَالصّبَاحَ،;
38+
وَلاحَ الشَّغُورُ لهَا وَالضّحَى;
39+
وَمَسّى الجُمَيْعيَّ دِئْدَاؤهَا;
40+
وَغَادَى الأضَارِعَ ثمّ الدَّنَا;
41+
فَيَا لَكَ لَيْلاً على أعْكُشٍ;
42+
أحَمَّ البِلادِ خَفِيَّ الصُّوَى;
43+
وَرَدْنَا الرُّهَيْمَةَ في جَوْزِهِ;
44+
وَبَاقيهِ أكْثَرُ مِمّا مَضَى;
45+
فَلَمّا أنَخْنَا رَكَزْنَا الرّمَاحَ ;
46+
بَين مَكارِمِنَا وَالعُلَى;
47+
وَبِتْنَا نُقَبّلُ أسْيَافَنَا;
48+
وَنَمْسَحُهَا من دِماءِ العِدَى;
49+
لِتَعْلَمَ مِصْرُ وَمَنْ بالعِراقِ;
50+
ومَنْ بالعَوَاصِمِ أنّي الفَتى;
51+
وَأنّي وَفَيْتُ وَأنّي أبَيْتُ;
52+
وَأنّي عَتَوْتُ على مَنْ عَتَا;
53+
وَمَا كُلّ مَنْ قَالَ قَوْلاً وَفَى;
54+
وَلا كُلُّ مَنْ سِيمَ خَسْفاً أبَى;
55+
وَلا بُدَّ للقَلْبِ مِنْ آلَةٍ;
56+
وَرَأيٍ يُصَدِّعُ صُمَّ الصّفَا;
57+
وَمَنْ يَكُ قَلْبٌ كَقَلْبي لَهُ;
58+
يَشُقُّ إلى العِزِّ قَلْبَ التَّوَى;
59+
وَكُلُّ طَرِيقٍ أتَاهُ الفَتَى;
60+
على قَدَرِ الرِّجْلِ فيه الخُطَى;
61+
وَنَام الخُوَيْدِمُ عَنْ لَيْلِنَا;
62+
وَقَدْ نامَ قَبْلُ عَمًى لا كَرَى;
63+
وَكانَ عَلى قُرْبِنَا بَيْنَنَا;
64+
مَهَامِهُ مِنْ جَهْلِهِ وَالعَمَى;
65+
وَمَنْ جَهِلَتْ نَفْسُهُ قَدْرَهُ;
66+
رَأى غَيرُهُ مِنْهُ مَا لا يَرَى
67+
"""
68+
```
69+
## Extracting Syllables
70+
Now let's try extracting the syllables for the first line. To do this, let's convert the text into a vector of stanzas of the poem. We therefore split the text on the `";\n"` separator, where the `\n` is the code for line break. The function `strip` simply removes the whitespaces before and after each stanza.
71+
```@example abc
72+
texts = map(x -> strip(string(x)), split.(poem, ";\n"))
73+
```
74+
Next is to initialize the syllabification for each stanza, suppose we want to capture the consonant before and after each vowel to represent one syllable. For example, for the word `basmala`, the syllabification if only the consonant preceding the vowel is considered then we have `ba`, `ma`, and `la`. To specify this configuration for the syllable, we do it as follows:
75+
```@repl abc
76+
syllable = Syllable(1, 0, 10)
77+
```
78+
Here the first argument represents the number of characters prior to the vowel is considered, the next argument which is 0 is the number of character after the vowel, and 10 the third argument simply mean how many vowels do we need to capture for each word. So that,
79+
```@repl abc
80+
r = Syllabification(false, syllable)
81+
```
82+
Then,
83+
```@repl abc
84+
r(string(split(texts[1], " ")[1]), isarabic=true, first_word=true, silent_last_vowel=false)
85+
```
86+
87+
## References
988
```@bibliography
1089
Pages = ["rhythmic_analysis.md"]
1190
Canonical = false

docs/src/man/symmetry_analysis.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Symmetric Analysis
22
=============
33
The work of [farrin2014structure](@citet)
44

5-
### References
5+
## References
66
```@bibliography
77
Pages = ["symmetry_analysis.md"]
88
Canonical = false

docs/src/man/text_alignment.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ count_aligned(res2[2,1])
186186
```
187187
## Visualization
188188
In this section, we are going to display the alignment by plotting the results.
189-
```@example abc
189+
```@repl abc
190190
using CairoMakie
191191
f, a, xys = plot(res1, :matches, nchars=60)
192192
a[1].xlabel = "Shamela0023790"
@@ -202,7 +202,7 @@ The figure above is divided into three subplots arranged in rows. You can think
202202
We added further customization to the plot, readers are encouraged to explore the API.
203203

204204
As for the plot of insertions of characters, we have:
205-
```@example abc
205+
```@repl abc
206206
f, a, xys = plot(res1, :insertions, nchars=60)
207207
a[1].xlabel = "Shamela0023790"
208208
a[1].xlabelsize = 20
@@ -213,7 +213,7 @@ a[3].xticks = 0:2:unique(xys[2][1])[end]
213213
f
214214
```
215215
For deletions, we have:
216-
```@example abc
216+
```@repl abc
217217
f, a, xys = plot(res1, :deletions, nchars=60)
218218
a[1].xlabel = "Shamela0023790"
219219
a[1].xlabelsize = 20
@@ -224,7 +224,7 @@ a[3].xticks = 0:2:unique(xys[2][1])[end]
224224
f
225225
```
226226
And for mismatches, we have
227-
```@example abc
227+
```@repl abc
228228
f, a, xys = plot(res1, :mismatches, nchars=60)
229229
a[1].xlabel = "Shamela0023790"
230230
a[1].xlabelsize = 20

docs/src/man/working_with_quran.md

Whitespace-only changes.

nb/nb14.jl

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
using DataFrames
2+
using QuranTree
3+
using Makie
4+
using Colors
5+
using CairoMakie
6+
using MakieThemes
7+
using Yunir
8+
9+
CairoMakie.activate!(type = "svg")
10+
active_theme = :dust
11+
12+
if active_theme == :earth
13+
Makie.set_theme!(ggthemr(:earth))
14+
current_theme = Dict(
15+
:background => "#36312C",
16+
:text => ["#555555", "#F8F8F0"],
17+
:line => ["#ffffff", "#827D77"],
18+
:gridline => "#504940",
19+
:swatch => ["#F8F8F0", "#DB784D", "#95CC5E", "#E84646", "#F8BB39", "#7A7267", "#E1AA93", "#168E7F", "#2B338E"],
20+
:gradient => ["#7A7267", "#DB784D"]
21+
)
22+
elseif active_theme == :dust
23+
Makie.set_theme!(ggthemr(:dust))
24+
current_theme = Dict(
25+
:background => "#FAF7F2",
26+
:text => ["#5b4f41", "#5b4f41"],
27+
:line => ["#8d7a64", "#8d7a64"],
28+
:gridline => "#E3DDCC",
29+
:swatch => ["#555555", "#db735c", "#EFA86E", "#9A8A76", "#F3C57B", "#7A6752", "#2A91A2", "#87F28A", "#6EDCEF"],
30+
:gradient => ["#F3C57B", "#7A6752"]
31+
)
32+
else
33+
error("No active_theme=" * string(active_theme))
34+
end;
35+
colors = [parse(Color, i) for i in current_theme[:swatch]]
36+
crps, tnzl = load(QuranData());
37+
crps_tbl = table(crps)
38+
tnzl_tbl = table(tnzl)
39+
40+
function last_syllable(bw_texts)
41+
bw1_texts = Array{String,1}()
42+
bw2_texts = Array{String,1}()
43+
bw3_texts = Array{String,1}()
44+
for bw_text in bw_texts
45+
@info bw_text
46+
push!(bw1_texts, replace(bw_text[end-3:end-2], "o" => ""))
47+
push!(bw2_texts, replace(bw_text[end-3:end-1], "o" => ""))
48+
push!(bw3_texts, replace(bw_text[end-4:end-1], "o" => ""))
49+
end
50+
return bw1_texts, bw2_texts, bw3_texts
51+
end
52+
53+
function encode_to_number(ychars::Array{String})
54+
y = unique(ychars)
55+
y_dict = Dict()
56+
for i in eachindex(y)
57+
if i == 1
58+
y_dict[y[i]] = i
59+
end
60+
61+
if y[i] .∈ Ref(Set(keys(y_dict)))
62+
continue
63+
else
64+
y_dict[y[i]] = i
65+
end
66+
end
67+
y_vec = Array{Int64,1}()
68+
for i in ychars
69+
push!(y_vec, y_dict[i])
70+
end
71+
return y_vec, y_dict # scaling to 100 since algo will fail saying range step cannot 0
72+
end
73+
74+
bw_texts = verses(crps_tbl[1])
75+
y1_chars, y2_chars, y3_chars = last_syllable(bw_texts)
76+
y1, y1_dict = encode_to_number(y1_chars)
77+
y2, y2_dict = encode_to_number(y2_chars)
78+
y3, y3_dict = encode_to_number(y3_chars)
79+
80+
f = Figure(resolution=(800, 800));
81+
a1 = Axis(f[1, 1],
82+
ylabel="Last Pronounced Syllable\n\n\n",
83+
title="Surah Al-Fatihah\n\n",
84+
yticks=(unique(y1), unique(string.(y1_chars))),
85+
xticks = collect(eachindex(y1_chars))
86+
)
87+
# ylims!(a1, 100, maximum(y1) .+1)
88+
89+
a2 = Axis(f[2, 1],
90+
ylabel="3 Characters\n\n\n",
91+
yticks=(unique(y2), unique(string.(y2_chars))),
92+
xticks = collect(eachindex(y2_chars))
93+
)
94+
95+
a3 = Axis(f[3, 1],
96+
ylabel="3-4 Characters\n\n",
97+
yticks=(unique(y3), unique(string.(y3_chars))),
98+
xticks = collect(eachindex(y3_chars))
99+
)
100+
101+
lines!(a1, collect(eachindex(y1_chars)), y1)
102+
hidexdecorations!(a1)
103+
lines!(a2, collect(eachindex(y2_chars)), y2)
104+
hidexdecorations!(a2)
105+
lines!(a3, collect(eachindex(y3_chars)), y3)
106+
107+
f
108+
109+
bw_texts = verses(crps_tbl[55])
110+
y1_chars, y2_chars, y3_chars = last_syllable(bw_texts)
111+
y1, y1_dict = encode_to_number(y1_chars)
112+
y2, y2_dict = encode_to_number(y2_chars)
113+
y3, y3_dict = encode_to_number(y3_chars)
114+
115+
# f = Figure(resolution=(500, 500));
116+
a1 = Axis(f[1, 2],
117+
# ylabel="Last Syllable",
118+
title="Surah Ar-Rahman\n\n",
119+
yticks=(unique(y1), unique(string.(y1_chars))),
120+
# xticks = collect(eachindex(y1_chars))
121+
)
122+
123+
a2 = Axis(f[2, 2],
124+
# ylabel="2-3 Characters",
125+
yticks=(unique(y2), unique(string.(y2_chars))),
126+
# xticks = collect(eachindex(y2_chars))
127+
)
128+
129+
a3 = Axis(f[3, 2],
130+
# ylabel="3-4 Characters",
131+
# yticks=(collect(eachindex(y3_chars)), string.(y3_chars)),
132+
# xticks = collect(eachindex(y3_chars))
133+
)
134+
135+
lines!(a1, collect(eachindex(y1_chars)), y1)
136+
hidexdecorations!(a1)
137+
lines!(a2, collect(eachindex(y2_chars)), y2)
138+
hidexdecorations!(a2)
139+
lines!(a3, collect(eachindex(y3_chars)), y3)
140+
f
141+
142+
# save("plots/plot_rhythmic1.svg", f)

0 commit comments

Comments
 (0)