Numbers2Words Greek
Project description
Numbers2Words Greek
Features
This repository contains code for converting converting numbers
to words (e.g. 10 -> δέκα) up until 10^13 - 1
(1 trillion minus one).
- Convert numbers to greek words.
- Support for ordinals.
- Support for certain time formats.
Installation:
You can install Numbers2Words Greek via pip from PyPI:
$ pip install Numbers2Words-Greek
If using poetry
, then you can do poetry add num2word-greek
.
To install this repository locally, in editable mode, do the following:
git clone https://github.com/geoph9/Numbers2Words-Greek.git
cd Numbers2Words-Greek
pip install -e .
If no error occurs then you are fine. To make sure, you may run:
python -c "import num2word"
.
Usage
The numbers2words.py
script:
This script contains functionality to convert numbers to their corresponding words in Greek. It only handles positive numbers (you can easily change it to handle negative ones) and can also handle decimals (only if the decimal part is separated using "," instead of ".") and hours (e.g. 2:30 -> δύο και μισή). It is important to note that this algorithm does not take into account the gender of the noun following each number. Also, the numbers will be converted as is and there is no post-processing like "2.5 ευρώ" -> "δυόμιση ευρώ" (the output will be "δύο κόμμα πέντε ευρώ").
If you only need to convert numbers to words then you may use this script as described below:
python -m num2word [--test-word <<WORD>>] [--path <<PATH>>] [--extension .lab] [--out-path]
Arguments:
-
-t
or--test-word
: Use this only for testing. Put a word or number after it and check the result. E.g.python -m num2word -t 150
should printεκατόν πενήντα
. -
-p
or--path
: Provide a valid path. The path must be either a text file or a directory containing many files (the extension of these files is defined by the-e
or--extension
option, defaults to.txt
). Cases:- Directory: Inside this directory there needs to be multiple text files which you want to convert. The words inside the file will not be change and only the numbers will be replaced by their corresponding words.
- File: If you provide a file then the same thing will happen but just for this file.
-
-e
or--extension
: Use this to change the extension of the text files you have provided in--path
. This only matters if you have provided a directory.
Example:
# num2word is the package and numbers2words.py is the script.
python -m num2word --path /home/user/data/transcriptions \
--extension .txt
The above will read all the .txt
files inside the transcriptions
directory and will change the numbers to their corresponding greek words.
Future Work:
- Handle fractions in
numbers2words
. E.g. Convert "1/10" to "ένα δέκατο". - Handle time input in
numbers2words
. E.g. Convert "11:20" to "έντεκα και είκοσι"
Contributing
Contributions are very welcome. To learn more, see the Contributor Guide.
License
Distributed under the terms of the MIT license, Numbers2Words Greek is free and open source software.
Issues
If you encounter any problems, please file an issue along with a detailed description.
Credits
This project was generated from @cjolowicz's Hypermodern Python Cookiecutter template.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for Numbers2Words-Greek-0.0.1a0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | c0f01183263387ee97dd23ef7aec523660d448d6ebc9b86ab92adee99376b604 |
|
MD5 | 7448f93ece0e0d2e3dd63ffb7c318512 |
|
BLAKE2b-256 | 07db9be741de887d7f5187addaab6a3b81a5fbaa3bc8984c1d69a26acfc8c8ca |
Hashes for Numbers2Words_Greek-0.0.1a0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0c5d6eb91cdb450d0ec76a2ecc4b017b403cf155d6854dc0562dad0fcdbfb379 |
|
MD5 | 60fb9d40d8d1bf39adc48e676299a872 |
|
BLAKE2b-256 | e857b34277b960bc5c84f5fdf28dadc8547b4776de287c3950ba0c37b3c3b009 |