Skip to main content

Georgian alphabet and language utilities for Natural Language Processing, script conversion and more.

Project description

AnbaniPy

tests codecov PyPI Python versions License: GPL v3

Georgian Python toolkit for NLP, Transliteration and more. Partially based on anbani.js.

Install

pip install anbani

Transliteration and NLP utilities need only hjson. PDF / e-book extraction (anbani.nlp.utils.ebook2text) additionally requires PyMuPDF:

pip install anbani[pdf]

Quickstart

Transliteration example:

from anbani.core.converter import convert, interpret

interpret("გამარჯობა", "asomtavruli")

# 'ႢႠႫႠႰႿႭႡႠ'

Georgianisation example:

from anbani.nlp.georgianisation import georgianise

georgianise("gamarjoba - rogor xar - rasa iqm - kaia kata - kai erti")

# 'გამარჯობა - როგორ ხარ - რასა იქმ - კაია კატა - კაი ერთი'

Convert ebooks with qwerty encoding to unicode Mkhedruli:

from anbani.nlp.utils import ebook2text
from anbani.core.converter import classify_text
from anbani.core.converter import convert

text = ebook2text("/home/george/Dev/georgian-text-corpus/sources/mylibrary/raw/files/ჩარლზ დიკენსი - დევიდ კოპერფილდი.pdf")
print(text[:300])

print(classify_text(text))

print(convert(text, "qwerty", "mkhedruli")[:300])

# Carlz dikensi daviT koperfildi Tavi pirveli dabadeba me viqnebi gmiri Cemive sakuTari Tavgadasavlisa Tu sxva...

# latin

# ჩარლზ დიკენსი დავით კოპერფილდი თავი პირველი დაბადება მე ვიქნები გმირი ჩემივე საკუთარი თავგადასავლისა თუ სხვა...

Expand contractions:

from anbani.nlp.contractions import expand_text

text = "ილია ჭავჭავაძე (დ. 8 ნოემბერი, 1837, სოფელი ყვარელი — გ. 12 სექტემბერი, 1907, წიწამური)"

print(text)
print(expand_text(text))

# ილია ჭავჭავაძე (დ. 8 ნოემბერი, 1837, სოფელი ყვარელი — გ. 12 სექტემბერი, 1907, წიწამური)
# ილია ჭავჭავაძე (დაბადება 8 ნოემბერი, 1837, სოფელი ყვარელი — გარდაცვალება 12 სექტემბერი, 1907, წიწამური)

Contract them back:

from anbani.nlp.contractions import contract_text

print(contract_text("მასის ატომური ერთეული და ასე შემდეგ"))

# მ.ა.ე. და ა.შ.

Text statistics & lorem

from anbani import toolkit, lorem

toolkit.frequency("ანბანი")   # per-letter frequencies
toolkit.friedman(text)         # index of coincidence
lorem.sentences(12)            # fake Georgian prose
lorem.names(3)                 # fake full names

Command line

Installing the package also installs an anbani command:

anbani interpret "gamarjoba"                      # -> ᲒᲐᲛᲐᲠᲯᲝᲑᲐ
anbani convert "ანბანი" -f mkhedruli -t asomtavruli
anbani georgianise "gamarjoba"
anbani expand "ვნახოთ ა. შ."
anbani lorem -w 8

Parity with anbani.js

anbani.py and anbani.js share one behavior contract, proved in CI by the byte-identical spec/golden.json that both test suites run. As of 3.0 they are feature-equivalent; the only intentional gaps are ebook2text (Python-only, needs PyMuPDF) and the browser/UMD bundle (js-only).

3.0 — breaking changes

  • classify_text returns "unknown" for undetectable / mixed-script text and now reports the four bicameral scripts; interpret raises on "unknown".
  • convert / interpret raise ValueError on an unsupported source or target (was an assertion, or a silent passthrough for targets).
  • georgianise defaults to mode="balanced" (was "accurate").

To-Do

Feel free to fork this repo!

  • Tokenizer
  • Transliteration
  • Expand contractions
  • ebook2text converter
  • Stemmer
  • Lemmatizer
  • Stopwords

Resources used

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

anbani-3.0.0.tar.gz (721.8 kB view details)

Uploaded Source

Built Distribution

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

anbani-3.0.0-py3-none-any.whl (723.6 kB view details)

Uploaded Python 3

File details

Details for the file anbani-3.0.0.tar.gz.

File metadata

  • Download URL: anbani-3.0.0.tar.gz
  • Upload date:
  • Size: 721.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for anbani-3.0.0.tar.gz
Algorithm Hash digest
SHA256 25ffa6f6754fa7a88f778b507579438b8c60c5a3cad5ba0b30c2ffbad1f31a56
MD5 e6f30a9641494723ebf00cdb46af9156
BLAKE2b-256 901c939f13e6c3c177ce4aaf253eec4c716acf0bb496172d477ce6c7e61662bc

See more details on using hashes here.

Provenance

The following attestation bundles were made for anbani-3.0.0.tar.gz:

Publisher: publish.yml on Anbani/anbani.py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file anbani-3.0.0-py3-none-any.whl.

File metadata

  • Download URL: anbani-3.0.0-py3-none-any.whl
  • Upload date:
  • Size: 723.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for anbani-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1d23eda74bcf10c414e065378c4a2b331c2b67ceade7e297f5f1791363fcb1ca
MD5 6c30883c44e9e0527e69336844c6d7f1
BLAKE2b-256 31c5a61196e940ae119efb8734870c424f1ffb469c61809a870912ea8280e85c

See more details on using hashes here.

Provenance

The following attestation bundles were made for anbani-3.0.0-py3-none-any.whl:

Publisher: publish.yml on Anbani/anbani.py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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