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

pip install belorthography

Usage

from belorthography import convert, Orthography

convert('Груша цвiла апошнi год.', Orthography.OFFICIAL, Orthography.LATIN)

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

Supported orthographies:

  • OFFICIAL (Narkamaŭka)
  • CLASSICAL (Taraškievica)
  • LATIN
  • LATIN_NO_DIACTRIC

Supported conversions

from / to official classical latin latin no diactric
official
classical
latin

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:

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-1.0.0.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

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

belorthography-1.0.0-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file belorthography-1.0.0.tar.gz.

File metadata

  • Download URL: belorthography-1.0.0.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.0

File hashes

Hashes for belorthography-1.0.0.tar.gz
Algorithm Hash digest
SHA256 f345bf38f623eb6e4bfde3a5ef5b73e9bcd8ab4359fe9028b21d01df9cdde63b
MD5 aa33f509babdd774134456680f7cadbc
BLAKE2b-256 86f2bb1762193c6ef2852012a22e83bed0087b2b7b38e32fc21e929696b38a30

See more details on using hashes here.

File details

Details for the file belorthography-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: belorthography-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.0

File hashes

Hashes for belorthography-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4038784a284fa5dbc1f5567a828fbcfb1e05b93d6a934ab49958ad5fc7e238bf
MD5 cff5b134256cb945a3957b2201c704b0
BLAKE2b-256 697729a068acc5c01c33356bc37bc24fc318281109e39e13e5c2931f8b83a5c6

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