-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
253 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# ABOUT CHURCH SLAVONIC NUMBERS | ||
|
||
## 1. Numerals | ||
|
||
Church Slavonic script (*further CU*) has individual numerals to represent numbers from 1 to 9, each round ten and each round hundred, for a total of 27 numerals. There's no zero digit. | ||
|
||
## 2. Basic numbers | ||
|
||
A number `x < 1000` in CU is represented by a succession of 1 to 3 CU digits that may contain a hundreds digit, a tens digit and a proper digit in that order. Digits representing numbers 11-19 are swapped places, wheter or not a hundreds digit is present. | ||
|
||
For the purpose of this program, this is to be referenced as a "hundred group". | ||
|
||
**Examples:** | ||
CU | Arabic | ||
---|--- | ||
а҃ | 1 | ||
і҃ | 10 | ||
р҃ | 100 | ||
ра҃і | 111 - note digit swapping | ||
рк҃а | 121 | ||
|
||
## 3. Thousands | ||
A number `x >= 1000` in CU is prepended with a "thousand" sign. For each "thousand" sign before a number, the number has to be mutiplied by one thousand. | ||
|
||
## 4. Number building | ||
|
||
Altogether, a complete number in CU consists of a succession of hundred groups with "thousand" signs inbetween. | ||
|
||
**Examples:** | ||
CU | Arabic | ||
---|--- | ||
а҃ | 1 | ||
҂а҃ | 1000 | ||
҂҂а҃ | 1000000 | ||
҂҂а҂аа҃ | 1001001 | ||
|
||
## 5. Decoration | ||
Finally, there is a "titlo" superscript sign that's obligatory to CU numbers. "Titlo" is placed in the number's rightmost hundred group; above the 2nd-from-last digit if it exists, otherwise above the only digit. | ||
|
||
**Examples:** | ||
|
||
See examples above. **NB:** in some (many) fonts "titlo" appears to follow after a digit, not above it. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,41 @@ | ||
A program for number convertion between Church Slavonic and arabic. | ||
# cu-numbers | ||
|
||
A program for numbers conversion between Church Slavonic script (*further CU*) and Arabic numerals. | ||
|
||
## Background | ||
|
||
See [Introduction](./INTRODUCTION.md) to learn about CU numbers. | ||
|
||
## Requirements | ||
|
||
Python >= 3.7 | ||
|
||
## Installation | ||
|
||
pip install cu-numbers | ||
|
||
## Usage | ||
|
||
import cunumbers | ||
|
||
# Convert an Arabic number to CU | ||
# Requires non-zero int, returns str | ||
|
||
a = cunumbers.arab_to_cu(1) | ||
|
||
# Convert a CU number to an Arabic | ||
# Requires str, returns int | ||
|
||
b = cunumbers.cu_to_arab("а҃") | ||
|
||
## Contributing | ||
|
||
Create an issue describing a bug or suggestion, then create a pull request mentioning the issue. | ||
|
||
## Feedback | ||
|
||
Drop me a line: [email protected] | ||
|
||
## License | ||
|
||
See [LICENSE](./LICENSE). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .cunumbers import arab_to_cu, cu_to_arab |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
[metadata] | ||
name = cu-numbers | ||
version = 1.0.0 | ||
author = Andrei Shur | ||
author_email = [email protected] | ||
description = Church Slavonic script numbers conversion | ||
long_description = file: README.md | ||
long_description_content_type = text/markdown | ||
url = https://github.com/endrain/cu-numbers | ||
keywords = church slavonic, conversion | ||
license = MIT | ||
classifiers = | ||
Development Status :: 5 - Production/Stable | ||
Programming Language :: Python :: 3.7 | ||
Programming Language :: Python :: 3.8 | ||
Programming Language :: Python :: 3.9 | ||
License :: OSI Approved :: MIT License | ||
Operating System :: OS Independent | ||
Intended Audience :: Religion | ||
Intended Audience :: Science/Research | ||
|
||
[options] | ||
include_package_data = True | ||
packages = cunumbers | ||
python_requires = >=3.7 |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import unittest, cunumbers | ||
arab_to_cu = cunumbers.arab_to_cu | ||
cu_to_arab = cunumbers.cu_to_arab | ||
|
||
class arab_to_cuTestCase(unittest.TestCase): | ||
def test_arab_to_cu_digits(self): | ||
self.assertEqual(arab_to_cu(1), "а҃") | ||
self.assertEqual(arab_to_cu(9), "ѳ҃") | ||
|
||
def test_arab_to_cu_tens(self): | ||
self.assertEqual(arab_to_cu(10), "і҃") | ||
self.assertEqual(arab_to_cu(18), "и҃і") | ||
self.assertEqual(arab_to_cu(22), "к҃в") | ||
|
||
def test_arab_to_cu_hundreds(self): | ||
self.assertEqual(arab_to_cu(100), "р҃") | ||
self.assertEqual(arab_to_cu(207), "с҃з") | ||
self.assertEqual(arab_to_cu(333), "тл҃г") | ||
|
||
def test_arab_to_cu_thousand(self): | ||
self.assertEqual(arab_to_cu(1000), "҂а҃") | ||
self.assertEqual(arab_to_cu(1006), "҂аѕ҃") | ||
self.assertEqual(arab_to_cu(1015), "҂ає҃і") | ||
self.assertEqual(arab_to_cu(1444), "҂аум҃д") | ||
|
||
def test_arab_to_cu_big(self): | ||
self.assertEqual(arab_to_cu(10001010001), "҂҂҂і҂҂а҂іа҃") | ||
self.assertEqual(arab_to_cu(50000000000), "҂҂҂н҃") | ||
self.assertEqual(arab_to_cu(60000070000), "҂҂҂ѯ҂ѻ҃") | ||
|
||
class cu_to_arabTestCase(unittest.TestCase): | ||
def test_cu_to_arab_digits(self): | ||
self.assertEqual(1, cu_to_arab("а҃")) | ||
self.assertEqual(9, cu_to_arab("ѳ")) | ||
|
||
def test_cu_to_arab_tens(self): | ||
self.assertEqual(10, cu_to_arab("і҃")) | ||
self.assertEqual(18, cu_to_arab("и҃і")) | ||
self.assertEqual(22, cu_to_arab("к҃в")) | ||
|
||
def test_cu_to_arab_hundreds(self): | ||
self.assertEqual(100, cu_to_arab("р҃")) | ||
self.assertEqual(207, cu_to_arab("с҃з")) | ||
self.assertEqual(333, cu_to_arab("тл҃г")) | ||
|
||
def test_cu_to_arab_thousands(self): | ||
self.assertEqual(1000, cu_to_arab("҂а҃")) | ||
self.assertEqual(1006, cu_to_arab("҂аѕ҃")) | ||
self.assertEqual(1015, cu_to_arab("҂ає҃і")) | ||
self.assertEqual(1444, cu_to_arab("҂аум҃д")) | ||
|
||
def test_cu_to_arab_big(self): | ||
self.assertEqual(10001010001, cu_to_arab("҂҂҂і҂҂а҂іа҃")) | ||
self.assertEqual(50000000000, cu_to_arab("҂҂҂н҃")) | ||
self.assertEqual(60000070000, cu_to_arab("҂҂҂ѯ҂ѻ҃")) | ||
|
||
def test_cu_to_arab_no_tsnd(self): | ||
self.assertEqual(80500690700, cu_to_arab("пфхчѱ҃")) | ||
|
||
def test_cu_to_arab_no_titlo(self): | ||
self.assertEqual(1, cu_to_arab("а")) | ||
|
||
def test_cu_to_arab_spaced(self): | ||
self.assertEqual(1, cu_to_arab("а҃ ")) | ||
|
||
def test_cu_to_arab_uppercase(self): | ||
self.assertEqual(1, cu_to_arab("А҃")) | ||
|
||
def test_cu_to_arab_mixed(self): | ||
self.assertEqual(2021, cu_to_arab(" вКА")) | ||
|
||
class ErrorTestCase(unittest.TestCase): | ||
def test_arab_to_cu_error(self): | ||
self.assertRaises(TypeError, arab_to_cu, "String") | ||
self.assertRaises(TypeError, arab_to_cu, 9.75) | ||
self.assertRaises(ValueError, arab_to_cu, 0) | ||
self.assertRaises(ValueError, arab_to_cu, -69) | ||
|
||
def test_cu_to_arab_error(self): | ||
self.assertRaises(TypeError, cu_to_arab, 420) | ||
self.assertRaises(ValueError, cu_to_arab, "A113") | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |