Skip to content

Commit

Permalink
version 0.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kariminf committed Jan 18, 2019
1 parent fa83ef2 commit 9921d2d
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 23 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## 0.4.0 (2019/01/18)

* Improved vocalizing letters
* Split text to parts
* Detecting verse feet with their types
* Affording mnemonics

## 0.3.0 (2019/01/11)

* Fix some buhuur
Expand Down
4 changes: 0 additions & 4 deletions aruudy/poetry/foot.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,3 @@ def __init__(self, var=[SALIM]):

]
self.init(var)

if __name__ == '__main__':
c = CVCCV([SALIM, KHABN, QATE])
print c.process("--u--u--u")
30 changes: 30 additions & 0 deletions tests/foot_t.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Copyright 2019 Abdelkrime Aries <[email protected]>
#
# ---- AUTHORS ----
# 2019 Abdelkrime Aries <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

import os
import sys

sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))

from aruudy.poetry import foot

c = foot.CVCCV([SALIM, KHABN, QATE])
print (c.process("--u--u--u"))
25 changes: 9 additions & 16 deletions tests/meter_u.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,41 +28,34 @@
from aruudy.poetry import meter
from aruudy.poetry.meter import Bahr, BahrError

mutadarik = {
"aname": u"متدارك",
"ename": "overtaking",
"trans": u"mutadārik",
"ameter": "",
"emeter": "S- S- S- S-", # - can be substituted for u u)
"key": u"حركات المحدث تنتقل فعلن فعلن فعلن فعل"
}

def test_name_type():
assert meter.name_type(u"كامل") == "aname"
assert meter.name_type(u"complete") == "ename"
assert meter.name_type(u"كامل") == "arabic"
assert meter.name_type(u"complete") == "english"

def test_get_bahr():
assert meter.get_bahr("overtaking") == mutadarik
assert meter.get_bahr("overtaking") == meter.mutadaarik.to_dict()
assert type(meter.get_bahr("overtaking")) is dict
assert meter.get_bahr("overtaking", dic=False) == Bahr(mutadarik)
assert meter.get_bahr("overtaking", dic=False) == meter.mutadaarik
assert type(meter.get_bahr("overtaking", dic=False)) is Bahr
assert meter.get_bahr("aaa") == None

def test_get_names():
assert meter.arabic_names()[0] == u"طويل"
assert meter.english_names()[0] == "long"
assert meter.trans_names()[0] == u"ṭawīl"
assert meter.get_names()[0]["trans"] == u"ṭawīl"

def test_bahr():
b = meter.get_bahr("overtaking", dic=False)

assert b.test_property("trans", u"mutadārik")
assert not b.test_property("trans", u"kamil")
assert b.test_property("name", u"mutadārik", "trans")
assert not b.test_property("name", u"kamil", "trans")
with pytest.raises(BahrError):
b.test_property("transliterate", u"kamil")

assert b.get_value("trans") == u"mutadārik"
assert b.get_value("name", "trans") == u"mutadārik"
with pytest.raises(BahrError):
b.get_value("transliterate")

assert b.to_dict() == mutadarik
assert b.to_dict() == meter.mutadaarik.to_dict()
5 changes: 5 additions & 0 deletions tests/prosody_t.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@

from aruudy.poetry import prosody

try:
UNICODE_EXISTS = bool(type(unicode))
except NameError:
unicode = lambda s: str(s)

orig = u"أَسِرْبَ القَطا هَلْ مَنْ يُعِيْرُ جَناحَهُ"

s = prosody.process_shatr(orig).to_dict()
Expand Down
10 changes: 7 additions & 3 deletions tests/prosody_u.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def test_normalize():

#private function
def test_prosody_del():
assert prosody._prosody_del(u"وَالشمس") == u"وَلشمس"
assert prosody._prosody_del(u"وَالشمس") == u"وَشمس"
assert prosody._prosody_del(u"فَالعلم") == u"فَلعلم"
assert prosody._prosody_del(u"فاستمعَ") == u"فستمعَ"
assert prosody._prosody_del(u"أَتَى المَظلوم إلَى القَاضِي فَأَنصفه قَاضِي العَدل") == u"أَتَ لمَظلوم إلَ لقَاضِي فَأَنصفه قَاضِ لعَدل"
Expand All @@ -49,7 +49,7 @@ def test_prosody_del():

def test_process_shatr ():
text = u"أَسِرْبَ القَطا هَلْ مَنْ يُعِيْرُ جَناحَهُ"
ameter = "vvcvcvvcvcvcvvcvvvcvvc"
ameter = "wwswswwswswswwswwwswws"

s = prosody.process_shatr(text)
assert type(s) == Shatr
Expand Down Expand Up @@ -77,12 +77,16 @@ def test_bahr_detection ():
exps = json.load(f)["exp"]

for exp in exps:
"""
try:
txt = exp["shatr"].encode()
out = exp["bahr"].encode()
except:
txt = exp["shatr"]
out = exp["bahr"]
"""
txt = unicode(exp["shatr"])
out = unicode(exp["bahr"])
#print (txt)
s = prosody.process_shatr(txt)
assert s.bahr.aname == out
assert s.bahr.name["arabic"] == out

0 comments on commit 9921d2d

Please sign in to comment.