skip to navigation
skip to content

pytransliter 1.0.2

PyTransliter is a text transliterator

PyTransliter

PyTransliter is a Python package designed for transliterate text by the rules of language pack.

Language packs

  • Russian
  • Ukrainian

Requirements

  • Python 3.x

Available imports

  • __doc__ - PyTransliter documentation
  • __version__ - PyTransliter version
  • Language - initialize language objects (language pack class)
  • get_language_names - return names of available language packs
  • get_language_codes - return codes of available language packs
  • add_language - add language pack
  • remove_language - remove language pack
  • reload_languages - reload default language packs (custom language packs will be removed)
  • translit - transliterate the string by the rules of language pack

Usage and examples

Required imports

>>> from pytransliter import get_language_codes, translit
>>>

Get language codes

>>> get_language_codes()
['ru', 'uk']
>>>

Transliterate Russian text

>>> text = 'Привет, мир!'
>>> translit(text, 'ru')
'Privjet, mir!'
>>>

Transliterate Ukrainian text

>>> text = 'Привіт, світ!'
>>> translit(text, 'uk')
'Pryvit, svit!'
>>>

Adding a custom language pack

Required imports

>>> from pytransliter import Language, add_language
>>>

1. Initialize language object.

>>> name = 'Name'
>>> code = 'code'
>>> dictionary = {'a': 'q', 'A': 'Q'}
>>> custom_language = Language(name, code, dictionary)
>>>

2. Add language pack.

>>> add_language(custom_language)
>>>

3. Check names of available language packs.

>>> get_language_names()
['Russian', 'Ukrainian', 'Name']
>>>

4. Check codes of available language packs.

>>> get_language_codes()
['ru', 'uk', 'code']
>>>

Removing language pack

Required imports

>>> from pytransliter import (get_language_names, get_language_codes,
...                           remove_language)
>>>

1. Check names of available language packs.

>>> get_language_names()
['Russian', 'Ukrainian', 'Name']
>>>

2. Check codes of available language packs.

>>> get_language_codes()
['ru', 'uk', 'code']
>>>

3. Remove language pack.

>>> remove_language('code')  # Code of language pack, which will be removed
>>>

4. Check names of available language packs again.

>>> get_language_names()
['Russian', 'Ukrainian']
>>>

5. Check codes of available language packs again.

>>> get_language_codes()
['ru', 'uk']
>>>

Reloading default language packs

Required imports

>>> from pytransliter import reload_languages
>>>

1. Check names of available language packs.

>>> get_language_names()
['Ukrainian', 'CustomLang']
>>>

2. Check codes of available language packs.

>>> get_language_codes()
['uk', 'customcode']
>>>

3. Reload default language packs.

>>> reload_languages()
>>>

4. Check names of available language packs again.

>>> get_language_names()
['Russian', 'Ukrainian']
>>>

5. Check codes of available language packs again.

>>> get_language_codes()
['ru', 'uk']
>>>

License

MIT

Author

natusaspire <natusaspire@gmail.com>

 
File Type Py Version Uploaded on Size
pytransliter-1.0.2.tar.gz (md5) Source 2017-10-06 5KB