Skip to main content

The module converts Arabic numerals to Greek and Roman numbers

Project description

English

Module converting Arabic numerals to Greek and Roman numbers

Version: 1.1.1
Supported Python: 3.11, 3.12, 3.13, 3.14, 3.15
Repository: GitHub - GreekRomanNumerical
License: Apache 2.0

Description

The library converts Arabic numbers, such as 1234, to Roman equivalents, such as MCCXXXIV, or Greek — Α_ΣΛΔ.

This module can also output Greek numbers in different formats. For example, the number 20005003001 can be represented as Κ___Ε__Γ_Α or Κ~Ε~Γ~Α. In addition, it is possible to output the text name of the digits, for example, Kappa macron Epsilon macron Gamma macron Alpha, or output them in lowercase.

Installation

Install the package using pip:

pip install GreekRomanUtils

Hybrid backend (Python + Rust)

Starting from this migration stage, the public API stays unchanged while internal conversion logic can run on a Rust backend.

  • Default behavior: try Rust backend first, fallback to Python automatically.
  • Force Python backend:
GREEKROMAN_FORCE_PYTHON=1

Development workflow with uv

Install dependencies:

uv sync --dev

Run tests in Python-only mode:

GREEKROMAN_FORCE_PYTHON=1 uv run pytest -v

Build/install Rust extension in editable mode for hybrid testing:

uv run maturin develop --manifest-path rust/Cargo.toml
uv run pytest -v

The structure of the project

There are two main classes: GreekConvert and RomanConvert. They implement the logic of converting to the corresponding numbers. There are also classes GreekAlphabet and RomanNumberAlphabet, which are used to store lists and dictionaries.
There are proprietary data types GreekNumber and RomanNumber for working with Greek and Roman numbers, which will allow you to perform basic mathematical operations with them.

Main functions

For "GreekConvert":

  • change_capital — A flag that controls the conversion of characters to upper or lower case.
  • change_positional — Change the positional mode for conversion.
  • convert — The function of converting an Arabic number to a Greek one, returns GreekNumber object. For example, the number 20005003001 is converted to Κ___Ε__Γ_Α (non-positional mode) or to Κ~Ε~Γ~Α (positional mode).
  • convert_to_arabic — A function for converting a Greek number to an Arabic one.
  • unicode_to_name — The function converts a Unicode character into its name.
  • name_to_unicode — The reverse operation for unicode_to_name.

The "GreekNumber" class:

  • set_number — Set a new value.
  • set_positional — Set the positional mode flag (affects display format: underscore _ for non-positional, tilde ~ for positional).
  • set_capital — Set the upper case flag.
  • get_number — Get the current number.
  • get_positional — Get the positional flag value.
  • get_capital — Get the capital flag value.
  • get_str — Get the textual representation of the number (e.g., "alpha beta gamma").
  • And basic mathematical operations (+, -, *, /, //, %, **, ==, !=, <, <=, >, >=).

For "RomanConvert":

  • convert — The method converts an Arabic number to a Roman number, returns RomanNumber object.
  • convert_to_arabic — The reverse method for convert.

For "RomanNumber":

  • set_number — Set a new value.
  • get_number — Get the current number.
  • get_value — Get the string representation of the Roman numeral.
  • And basic mathematical operations (+, -, *, /, //, %, **, ==, !=, <, <=, >, >=).

Ru

Модуль преобразование арабских цифр в греческие и римские числа

Версия: 1.1.1
Поддерживаемые версии Python: 3.11, 3.12, 3.13, 3.14, 3.15
Репозиторий: GitHub - GreekRomanNumerical
Лицензия: Apache 2.0

Описание

Библиотека преобразует арабские числа, такие как 1234, в римские эквиваленты, например, MCCXXXIV, или греческие — Α_ΣΛΔ.

Также этот модуль может выводить греческие цифры в разных форматах. Например, число 20005003001 можно представить как Κ___Ε__Γ_Α или Κ~Ε~Γ~Α. Кроме того, есть возможность выводить текстовое название цифр, например, Kappa macron Epsilon macron Gamma macron Alpha, или выводить их в нижнем регистре.

Установка

Установите пакет с помощью pip:

pip install GreekRomanUtils

Гибридный backend (Python + Rust)

На этапе миграции публичный API не меняется, но внутренняя логика конвертации может выполняться через Rust backend.

  • Поведение по умолчанию: сначала попытка Rust backend, при недоступности автоматический fallback на Python.
  • Принудительное отключение Rust backend:
GREEKROMAN_FORCE_PYTHON=1

Локальный workflow через uv

Установка зависимостей:

uv sync --dev

Запуск тестов в Python-only режиме:

GREEKROMAN_FORCE_PYTHON=1 uv run pytest -v

Сборка/подключение Rust-расширения для hybrid-режима:

uv run maturin develop --manifest-path rust/Cargo.toml
uv run pytest -v

Структура пректа

Есть два основных класса: GreekConvert и RomanConvert. Они реализуют логику преобразования в соответствующие числа. Также есть классы GreekAlphabet и RomanNumberAlphabet, которые используются для хранения списков и словарей.
Есть собственные типы данных GreekNumber и RomanNumber для работы с греческими и римскими числами, что позволит выполнять с ними базовые математические операции.

Основные функции

Для «GreekConvert»:

  • change_capital — Флаг, управляющий преобразованием символов в верхний или нижний регистр.
  • change_positional — Изменить режим позиционного преобразования.
  • convert — Функция преобразования арабского числа в греческое, возвращает объект GreekNumber. Например, число 20005003001 преобразуется в Κ___Ε__Γ_Α (непозиционный режим) или в Κ~Ε~Γ~Α (позиционный режим).
  • convert_to_arabic — Функция преобразования греческого числа в арабское.
  • unicode_to_name — Функция преобразует символ Unicode в его название.
  • name_to_unicode — Обратная операция для unicode_to_name.

Класс «GreekNumber»:

  • set_number — Установить новое значение.
  • set_positional — Установить флаг позиционного режима (влияет на формат отображения: подчеркивание _ для непозиционного, тильда ~ для позиционного).
  • set_capital — Установить флаг верхнего регистра.
  • get_number — Получить текущее число.
  • get_positional — Получить значение флага позиционности.
  • get_capital — Получить значение флага регистра.
  • get_str — Получить текстовое представление числа (например, "alpha beta gamma").
  • И базовые математические операции (+, -, *, /, //, %, **, ==, !=, <, <=, >, >=).

Для «RomanConvert»:

  • convert — Метод преобразует арабское число в римское, возвращает объект RomanNumber.
  • convert_to_arabic — Обратный метод для convert.

Для «RomanNumber»:

  • set_number — Установить новое значение.
  • get_number — Получить текущее число.
  • get_value — Получить строковое представление римского числа.
  • И базовые математические операции (+, -, *, /, //, %, **, ==, !=, <, <=, >, >=).

Схема пректа
ScheemProject

License

Apache License 2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

greekromanutils-1.1.1.tar.gz (1.2 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

greekromanutils-1.1.1-cp311-abi3-win_amd64.whl (126.8 kB view details)

Uploaded CPython 3.11+Windows x86-64

greekromanutils-1.1.1-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (262.0 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.17+ x86-64

greekromanutils-1.1.1-cp311-abi3-macosx_11_0_arm64.whl (230.9 kB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

File details

Details for the file greekromanutils-1.1.1.tar.gz.

File metadata

  • Download URL: greekromanutils-1.1.1.tar.gz
  • Upload date:
  • Size: 1.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for greekromanutils-1.1.1.tar.gz
Algorithm Hash digest
SHA256 136a8180e9aeb3d7a632fe42ef13fcdaf6e281573177b2c6beb1007b3439bf99
MD5 99e76f3e5bac35df92779ee2145fcb77
BLAKE2b-256 38d41a69cf5ccd3348a342b2dd5d68aca39d9425e65321a3e8278411b6e1b893

See more details on using hashes here.

File details

Details for the file greekromanutils-1.1.1-cp311-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for greekromanutils-1.1.1-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 223c8c3001484e572a24a19fea2f69d106531449001d71bd78c6c89b83ef3554
MD5 9f6617d51ab84d7b79658c1b26bcb7d6
BLAKE2b-256 fa935372e37b539d4486f4216633d682c658fe61d805651faadf4303926d350f

See more details on using hashes here.

File details

Details for the file greekromanutils-1.1.1-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for greekromanutils-1.1.1-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2847b2758731ba8e86fa9a37477fc10e7df1a0d980c52420479818358aa04481
MD5 661446461a787b88a4a8bf3d1ea742c0
BLAKE2b-256 2b6e54f9bcd29651f86a6c97897dab13e68488cc270bfa141a4a7646ef01f88e

See more details on using hashes here.

File details

Details for the file greekromanutils-1.1.1-cp311-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for greekromanutils-1.1.1-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 09d0bcab9d458ee4a2d5b2250262e9298e8d8e0c21faa27c08e3b2768284df6d
MD5 30278ae978a203cea8578ad8ad33eb6d
BLAKE2b-256 b2e3082345cf873eb95b701f1eb6f86b4e363a968c86bd1c451564e3a80c7e21

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page