Skip to content

Commit

Permalink
Finalizing jummal
Browse files Browse the repository at this point in the history
  • Loading branch information
iamjazzar committed Jun 4, 2022
1 parent 938e6a9 commit 0a46724
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 65 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Jummal [![Tests](https://github.com/iamjazzar/jummal/actions/workflows/ci.yml/badge.svg)](https://github.com/iamjazzar/jummal/actions/workflows/ci.yml) [![PyPI version](https://badge.fury.io/py/jummal.svg)](https://badge.fury.io/py/jummal)
# Kalam [![Tests](https://github.com/iamjazzar/matn/actions/workflows/ci.yml/badge.svg)](https://github.com/iamjazzar/matn/actions/workflows/ci.yml) [![PyPI version](https://badge.fury.io/py/matn.svg)](https://badge.fury.io/py/matn)



Expand All @@ -8,7 +8,7 @@
## Getting started

```bash
pip install jummal
pip install matn
```

## Usage
Empty file removed jummal/__init__.py
Empty file.
23 changes: 0 additions & 23 deletions jummal/cli.py

This file was deleted.

1 change: 1 addition & 0 deletions matn/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from matn.jummal import processor as jummal # noqa
30 changes: 30 additions & 0 deletions matn/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import argparse

from matn import jummal


def get_args():
parser = argparse.ArgumentParser(
description="A mathmatical tool for Arabic counting systems."
)
parser.add_argument(
"processor",
choices=["jummal"],
help="the processor to be applied on the given string.",
)
parser.add_argument(
"text",
type=str,
help="The string to be counted",
)

return parser.parse_args()


def main():
args = get_args()
print(jummal(args.text))


if __name__ == "__main__":
exit(main())
2 changes: 1 addition & 1 deletion jummal/processor.py → matn/jummal.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
}


def jummal_counter(text: str, use_hamza: bool = False, use_tarkeeb: bool = False):
def processor(text: str, use_hamza: bool = False, use_tarkeeb: bool = False):
total = len(text)
count = 0
skip = False
Expand Down
8 changes: 4 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
long_description = (this_directory / "README.md").read_text()

setup(
name="jummal",
name="matn",
version="0.1.1",
packages=["jummal"],
packages=["matn"],
install_requires=[],
entry_points={
"console_scripts": [
"jummal = jummal.cli:main",
"matn = matn.cli:main",
],
},
classifiers=[
Expand All @@ -28,7 +28,7 @@
"License :: OSI Approved :: MIT License",
"Topic :: Software Development",
],
url="https://github.com/iamjazzar/jummal",
url="https://github.com/iamjazzar/matn",
license="MIT License",
author="Ahmed Jazzar",
author_email="me@ahmedjazzar.com", # TODO
Expand Down
66 changes: 33 additions & 33 deletions tests/test_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

from ddt import data, ddt, unpack

from jummal.processor import jummal_counter
from matn.jummal import processor as jummal


@ddt
class TestJummalNormal(TestCase):
def wrapper(self, text):
return jummal_counter(text)
return jummal(text)

@data(
["أ", 1],
Expand Down Expand Up @@ -41,7 +41,7 @@ def wrapper(self, text):
["غ", 1_000],
)
@unpack
def test_jummal_counter_single_character(self, text, expected):
def test_jummal_single_character(self, text, expected):
assert expected == self.wrapper(text), text

@data(
Expand All @@ -51,7 +51,7 @@ def test_jummal_counter_single_character(self, text, expected):
["من أنبت الغصن من صمصامة ذكر", 2_990],
)
@unpack
def test_jummal_counter_sentences(self, text, expected):
def test_jummal_sentences(self, text, expected):
assert expected == self.wrapper(text), text

@data(
Expand All @@ -62,7 +62,7 @@ def test_jummal_counter_sentences(self, text, expected):
["ظن", 950],
)
@unpack
def test_jummal_counter_words(self, text, expected):
def test_jummal_words(self, text, expected):
assert expected == self.wrapper(text), text

@data(
Expand All @@ -75,22 +75,22 @@ def test_jummal_counter_words(self, text, expected):
["ًرمى القضاء بعيني جؤذر أسدا", 2_299],
)
@unpack
def test_jummal_counter_hamza(self, text, expected):
def test_jummal_hamza(self, text, expected):
assert expected == self.wrapper(text), text

@data(
["بكى", 32],
)
@unpack
def test_jummal_counter_alef_maksora(self, text, expected):
def test_jummal_alef_maksora(self, text, expected):
assert expected == self.wrapper(text), text

@data(
["حمزة", 60],
["أبكمه", 68],
)
@unpack
def test_jummal_counter_heh_teh_marboota(self, text, expected):
def test_jummal_heh_teh_marboota(self, text, expected):
assert expected == self.wrapper(text), text

@data(
Expand All @@ -102,14 +102,14 @@ def test_jummal_counter_heh_teh_marboota(self, text, expected):
["بغاء", 1_003],
)
@unpack
def test_jummal_counter_tarkeeb(self, text, expected):
def test_jummal_tarkeeb(self, text, expected):
assert expected == self.wrapper(text), text


@ddt
class TestJummalUseTarkeeb(TestCase):
def wrapper(self, text):
return jummal_counter(text, use_tarkeeb=True)
return jummal(text, use_tarkeeb=True)

@data(
["أ", 1],
Expand Down Expand Up @@ -142,7 +142,7 @@ def wrapper(self, text):
["غ", 1_000],
)
@unpack
def test_jummal_counter_single_character(self, text, expected):
def test_jummal_single_character(self, text, expected):
assert expected == self.wrapper(text), text

@data(
Expand All @@ -152,7 +152,7 @@ def test_jummal_counter_single_character(self, text, expected):
["من أنبت الغصن من صمصامة ذكر", 31_960],
)
@unpack
def test_jummal_counter_sentences(self, text, expected):
def test_jummal_sentences(self, text, expected):
assert expected == self.wrapper(text), text

@data(
Expand All @@ -163,7 +163,7 @@ def test_jummal_counter_sentences(self, text, expected):
["ظن", 950],
)
@unpack
def test_jummal_counter_words(self, text, expected):
def test_jummal_words(self, text, expected):
assert expected == self.wrapper(text), text

@data(
Expand All @@ -176,22 +176,22 @@ def test_jummal_counter_words(self, text, expected):
["ًرمى القضاء بعيني جؤذر أسدا", 2_299],
)
@unpack
def test_jummal_counter_hamza(self, text, expected):
def test_jummal_hamza(self, text, expected):
assert expected == self.wrapper(text), text

@data(
["بكى", 32],
)
@unpack
def test_jummal_counter_alef_maksora(self, text, expected):
def test_jummal_alef_maksora(self, text, expected):
assert expected == self.wrapper(text), text

@data(
["حمزة", 60],
["أبكمه", 68],
)
@unpack
def test_jummal_counter_heh_teh_marboota(self, text, expected):
def test_jummal_heh_teh_marboota(self, text, expected):
assert expected == self.wrapper(text), text

@data(
Expand All @@ -203,14 +203,14 @@ def test_jummal_counter_heh_teh_marboota(self, text, expected):
["بغاء", 2_001],
)
@unpack
def test_jummal_counter_tarkeeb(self, text, expected):
def test_jummal_tarkeeb(self, text, expected):
assert expected == self.wrapper(text), text


@ddt
class TestJummalUseHamza(TestCase):
def wrapper(self, text):
return jummal_counter(text, use_hamza=True)
return jummal(text, use_hamza=True)

@data(
["أ", 1],
Expand Down Expand Up @@ -243,7 +243,7 @@ def wrapper(self, text):
["غ", 1_000],
)
@unpack
def test_jummal_counter_single_character(self, text, expected):
def test_jummal_single_character(self, text, expected):
assert expected == self.wrapper(text), text

@data(
Expand All @@ -253,7 +253,7 @@ def test_jummal_counter_single_character(self, text, expected):
["من أنبت الغصن من صمصامة ذكر", 2_990],
)
@unpack
def test_jummal_counter_sentences(self, text, expected):
def test_jummal_sentences(self, text, expected):
assert expected == self.wrapper(text), text

@data(
Expand All @@ -264,7 +264,7 @@ def test_jummal_counter_sentences(self, text, expected):
["ظن", 950],
)
@unpack
def test_jummal_counter_words(self, text, expected):
def test_jummal_words(self, text, expected):
assert expected == self.wrapper(text), text

@data(
Expand All @@ -277,22 +277,22 @@ def test_jummal_counter_words(self, text, expected):
["ًرمى القضاء بعيني جؤذر أسدا", 2_300],
)
@unpack
def test_jummal_counter_hamza(self, text, expected):
def test_jummal_hamza(self, text, expected):
assert expected == self.wrapper(text), text

@data(
["بكى", 32],
)
@unpack
def test_jummal_counter_alef_maksora(self, text, expected):
def test_jummal_alef_maksora(self, text, expected):
assert expected == self.wrapper(text), text

@data(
["حمزة", 60],
["أبكمه", 68],
)
@unpack
def test_jummal_counter_heh_teh_marboota(self, text, expected):
def test_jummal_heh_teh_marboota(self, text, expected):
assert expected == self.wrapper(text), text

@data(
Expand All @@ -304,14 +304,14 @@ def test_jummal_counter_heh_teh_marboota(self, text, expected):
["بغاء", 1_004],
)
@unpack
def test_jummal_counter_tarkeeb(self, text, expected):
def test_jummal_tarkeeb(self, text, expected):
assert expected == self.wrapper(text), text


@ddt
class TestJummalTarkeebAndHamza(TestCase):
def wrapper(self, text):
return jummal_counter(text, use_hamza=True, use_tarkeeb=True)
return jummal(text, use_hamza=True, use_tarkeeb=True)

@data(
["أ", 1],
Expand Down Expand Up @@ -344,7 +344,7 @@ def wrapper(self, text):
["غ", 1_000],
)
@unpack
def test_jummal_counter_single_character(self, text, expected):
def test_jummal_single_character(self, text, expected):
assert expected == self.wrapper(text), text

@data(
Expand All @@ -354,7 +354,7 @@ def test_jummal_counter_single_character(self, text, expected):
["من أنبت الغصن من صمصامة ذكر", 31_960],
)
@unpack
def test_jummal_counter_sentences(self, text, expected):
def test_jummal_sentences(self, text, expected):
assert expected == self.wrapper(text), text

@data(
Expand All @@ -365,7 +365,7 @@ def test_jummal_counter_sentences(self, text, expected):
["ظن", 950],
)
@unpack
def test_jummal_counter_words(self, text, expected):
def test_jummal_words(self, text, expected):
assert expected == self.wrapper(text), text

@data(
Expand All @@ -378,22 +378,22 @@ def test_jummal_counter_words(self, text, expected):
["ًرمى القضاء بعيني جؤذر أسدا", 2_300],
)
@unpack
def test_jummal_counter_hamza(self, text, expected):
def test_jummal_hamza(self, text, expected):
assert expected == self.wrapper(text), text

@data(
["بكى", 32],
)
@unpack
def test_jummal_counter_alef_maksora(self, text, expected):
def test_jummal_alef_maksora(self, text, expected):
assert expected == self.wrapper(text), text

@data(
["حمزة", 60],
["أبكمه", 68],
)
@unpack
def test_jummal_counter_heh_teh_marboota(self, text, expected):
def test_jummal_heh_teh_marboota(self, text, expected):
assert expected == self.wrapper(text), text

@data(
Expand All @@ -405,5 +405,5 @@ def test_jummal_counter_heh_teh_marboota(self, text, expected):
["بغاء", 2_002],
)
@unpack
def test_jummal_counter_tarkeeb(self, text, expected):
def test_jummal_tarkeeb(self, text, expected):
assert expected == self.wrapper(text), text
Loading

0 comments on commit 0a46724

Please sign in to comment.