Skip to main content

Library for converting Belarusian text to different orthographies (e.g. lacinka).

Project description

Belorthography

Python 3 library for converting Belarusian text various orthographies (e.g. lacinka).

Install

TODO

Usage

from belorthography import convert, Case

print(convert('Груша цвiла апошнi год.', Case.CYR_NAR, Case.LAT))

# prints "Hruša cviła apošni hod."

Development

Create Python virtual enviroment

Ensure venv is installed:

apt-get install python3-venv

In the project folder run:

python -m venv ./venv
source ./venv/bin/activate

Setup package and run tests:

python setup.py develop
pip install -r requirements.txt
pytest

Diff mode

Diff mode helps to see if changes to translation algorithms have any effect. it is useful during development, especially while we are working on an existing algorithm that we don't fully understand yet. Steps to use it:

  1. Guard changes using diff_mode.is_new() condition. For example in order to test whether removal of some conversion affects results:
# somewhere in conversion algorithm...
# Check if removal of сслі => ślli replacement has any effect.
# Control version is replacement is present while new version is replacement removed.
if not diff_mode.is_new():
    res = res.replace('сллі', 'ślli')
  1. Run diff tool:
python diff.py

It will go through a set of Belarusian texts, converting each into Lacinka twice: once with is_new() being set to False (golden) and once with it set to True (test). If there are changes - they will be printed an a html file with nice handy UI.

  1. Run tests:
DIFF_NEW=true pytest

This will run unit tests with is_new() being set to true. This helps to quickly see if the change affects existing tests. If you change affects a set of sample texts from step 2 but doesn't affect any unit tests - consider adding a new unit test.

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

belorthography-0.0.1.tar.gz (10.0 kB view hashes)

Uploaded Source

Built Distribution

belorthography-0.0.1-py3-none-any.whl (9.1 kB view hashes)

Uploaded Python 3

Supported by

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