Skip to main content

AsoSoft Library (Python)

AsoSoft Library offers basic natural language processing (NLP) algorithms for the Kurdish Language (ckb: Central branch of Kurdish). AsoSoft Library is originally written in C# and this library is the Python port.

  • Grapheme-to-Phoneme (G2P) converter and Transliteration: converts Kurdish text into syllabified phoneme string. Also transliterates Kurdish texts from Arabic script into Latin script and vice versa.
  • Normalizer: normalizes the Kurdish text and punctuation marks, unifies numerals, replaces Html Entities, extracts and replaces URLs and emails, and more.
  • Numeral Converter: converts any type of numbers into Kurdish words.
  • Sort: Sorts a list in correct Kurdish alphabet order.
  • Poem Meter Classifier: Classifies the meter of the input Kurdish poem

How to use?

  • Python version: Python 3.11+
  • Install package using pip: pip install asosoft
  • Import package in your py file:
import asosoft

Development

AsoSoft Library is developed and maintained by Aso Mahmudi. AsoSoft Library is written in C# (.NET 6).

Grapheme-to-Phoneme (G2P) converter and Transliteration

This function is based on the study "Automated Grapheme-to-Phoneme Conversion for Central Kurdish based on Optimality Theory".

Kurdish G2P converter

Converts Central Kurdish text in standard Arabic script into syllabified phonemic Latin script (i.e. graphemes to phonems)

General format:

asosoft.KurdishG2P(text, convertNumbersToWord = False, backMergeConjunction = True, singleOutputPerWord = True)

An example:

>>> print(asosoft.KurdishG2P("شەو و ڕۆژ بووین بە گرفت. درێژیی دیوارەکەی گرتن"))
ˈşeˈwû ˈřoj ˈbûyn ˈbe ˈgiˈrift. ˈdiˈrêˈjîy ˈdîˈwaˈreˈkey ˈgirˈtin

Transliteration

Arabic script into Hawar Latin script (ح‌غ‌ڕڵ→ḧẍřł):

>>> print(asosoft.Ar2La("گیرۆدەی خاڵی ڕەشتە؛ گوێت لە نەغمەی تویوورە؟"))
gîrodey xałî řeşte; gwêt le neẍmey tuyûre?

Arabic script into the Latin script suggested by Dr. Feryad Fazil Omar:

>>> print(asosoft.Ar2LaFeryad("گیرۆدەی خاڵی ڕەشتە؛ گوێت لە نەغمەی تویوورە؟"))
gîrodey xaḻî ṟeşte; gwêt le nex̱mey tuyûre?

Arabic script into simplified (ح‌غ‌ڕڵ→hxrl) Hawar Latin script:

>>> print(asosoft.Ar2LaSimple("گیرۆدەی خاڵی ڕەشتە؛ گوێت لە نەغمەی تویوورە؟"))
gîrodey xalî reşte; gwêt le nexmey tuyûre?

Latin script (Hawar) into Arabic script:

>>> print(asosoft.La2Ar("Gelî keç û xortên kurdan, hûn hemû bi xêr biçin"))
گەلی کەچ و خۆرتێن کوردان، هوون هەموو ب خێر بچن

Arabic script into IPA:

>>> print(asosoft.Phonemes2IPA(asosoft.KurdishG2P("شەو و ڕۆژ بووین بە گرفت. درێژیی دیوارەکە گرتن")))
ʃa·wu ro̞ʒ bujn ba gɪ·ɾɪft. dɪ·ɾɛ·ʒij di·wä·ɾa·ka gɪɾ·tɪn

Kurdish Text Normalizer

Several functions needed for Central Kurdish text normalization:

Normalize Kurdish

Two character replacement lists are provided as the resources of the library:

  • Deep Unicode Corrections:
    • replacing deprecated Arabic Presentation Forms (FB50–FDFF and FE70–FEFF) with corresponding standard characters.
    • replacing different types of dashes and spaces
    • removing Unicode control character
  • Additional Unicode Corrections
    • replacing special Arabic math signs with corresponding Latin characters
    • replacing similar, but different letters with standard characters (e.g. ڪ,ے,ٶ with ک,ی,ؤ)

The normalization task in this function:

  • for all Arabic scripts (including Kurdish, Arabic, and Persian):
    • Character-based replacement:
      • Above mentioned replacement lists
      • Private Use Area (U+E000 to U+F8FF) with White Square character
  • Standardizing and removing duplicated or unnecessary Zero-Width characters
  • removing unnecessary Tatweels (U+0640)
  • only for Central Kurdish:
    • standardizing Kurdish characters: ە, هـ, ی, and ک
    • correcting miss-converted characters from non-Unicode fonts
    • replacing word-initial ر with ڕ

the simple overloading:

>>> print(asosoft.Normalize("دەقے شیَعري خـــۆش. ره‌نگه‌كاني خاك"))
دەقی شێعری خۆش. ڕەنگەکانی خاک

or the complete overloading:

>>> asosoft.Normalize(text, isOnlyKurdish=True, changeInitialR=True, deepUnicodeCorrectios=True, additionalUnicodeCorrections=True, usersReplaceList)

AliK to Unicode

AliK2Unicode converts Kurdish text written in AliK fonts (developed by Abas Majid in 1997) into Unicode standard. Ali-K fonts: Alwand, Azzam, Hasan, Jiddah, kanaqen, Khalid, Sahifa, Sahifa Bold, Samik, Sayid, Sharif, Shrif Bold, Sulaimania, Traditional

>>> print(asosoft.AliK2Unicode("ئاشناكردنى خويَندكار بة طوَرِانكاريية كوَمةلاَيةتييةكان"))
ئاشناکردنی خوێندکار بە گۆڕانکارییە کۆمەڵایەتییەکان

AliWeb to Unicode

AliWeb2Unicode converts Kurdish text written in AliK fonts into Unicode standard. Ali-Web fonts: Malper, Malper Bold, Samik, Traditional, Traditional Bold

>>> print(asosoft.AliWeb2Unicode("هةر جةرةيانصکي مصذووُيي کة أوو دةدا"))
ھەر جەرەیانێکی مێژوویی کە ڕوو دەدا

Dylan to Unicode

Dylan2Unicode converts Kurdish text written in Dylan fonts (developed by Dylan Saleh at KurdSoft in 2001) into Unicode standard.

>>> print(asosoft.Dylan2Unicode("لثكؤلثنةران بؤيان دةركةوتووة كة دةتوانث بؤ لةش بةكةصك بث"))
لێکۆلێنەران بۆیان دەرکەوتووە کە دەتوانێ بۆ لەش بەکەڵک بێ

Zarnegar to Unicode

Zarnegar2Unicode converts Kurdish text written in Zarnegar word processor (developed by SinaSoft with RDF converter by NoorSoft) and into Unicode standard.

>>> print(asosoft.Zarnegar2Unicode("بلٌيٌين و بگه‌رٍيٌين بوٌ هه‌لاٌلٌه‌ى سىٌيه‌مى فه‌لسه‌فه"))
بڵێین و بگەڕێین بۆ هەڵاڵەی سێیەمی فەلسەفە

NormalizePunctuations

NormalizePunctuations corrects spaces before and after of the punctuations. When seprateAllPunctuations is true,

>>> print(asosoft.NormalizePunctuations("دەقی«کوردی » و ڕێنووس ،((خاڵبەندی )) چۆنە ؟", false))
دەقی «کوردی» و ڕێنووس، «خاڵبەندی» چۆنە؟

Trim Line

Trim starting and ending white spaces (including zero width spaces) of line, TrimLine

>>> print(TrimLine("   دەق\u200c  "))
دەق

Replace Html Entities

ReplaceHtmlEntity replaces HTML Entities with single Unicode characters (e.g. "é" with "é"). It is useful in web crawled corpora.

>>> print(asosoft.ReplaceHtmlEntity("ئێوە "دەق" بە زمانی <کوردی> دەنووسن"))
ئێوە "دەق" بە زمانی <کوردی> دەنووسن

Replace URLs and emails

ReplaceUrlEmail replaces URLs and emails with a certain word. It improves language models.

Unify Numerals

UnifyNumerals unifies numeral characters into desired numeral type from en (0123456789) or ar (٠١٢٣٤٥٦٧٨٩)

>>> print(asosoft.UnifyNumerals("ژمارەکانی ٤٥٦ و ۴۵۶ و 456", "en"))
ژمارەکانی 456 و 456 و 456

Seperate Digits from words

SeperateDigits add a space between joined numerals and words (e.g. replacing "12کەس" with "12 کەس"). It improves language models.

>>> print(asosoft.SeperateDigits("لە ساڵی1950دا1000دۆلاریان بە 5کەس دا"))
لە ساڵی 1950 دا 1000 دۆلاریان بە 5 کەس دا

Word to Word Replacment

Word2WordReplacement applies a "string to string" replacement dictionary on the text. It replaces the full-matched words not a part of them.

>>> print(asosoft.Word2WordReplacement("مال، نووری مالیکی", {"مال": "ماڵ", "سلاو": "سڵاو"}))
ماڵ، نووری مالیکی

Character to Character Replacment

Char2CharReplacment applies a "char to char" replacement dictionary on the text. It uses as the final step needed for some non-Unicode systems.

Kurdish Numeral converter

It converts numerals into Central Kurdish words. It is useful in text-to-speech tools.

  • integers (1100 => )
  • floats (10.11)
  • negatives (-10.11)
  • percent (100% or %100)
  • querency marks ($100, £100, and €100)
>>> print(asosoft.Number2Word("لە ساڵی 1999دا بڕی 40% لە پارەکەیان واتە $102.1 یان وەرگرت"))
لە ساڵی هەزار و نۆسەد و نەوەد و نۆدا بڕی چل لە سەد لە پارەکەیان واتە سەد و دوو پۆینت یەک دۆلاریان وەرگرت

Kurdish Sort

Sorting a string list in correct order of Kurdish alphabet ("ئءاآأإبپتثجچحخدڎذرڕزژسشصضطظعغفڤقكکگلڵمنوۆۊۉهھەیێ")

>>> myList = ["یەک", "ڕەنگ", "ئەو", "ئاو", "ڤەژین", "فڵان"]
>>> print(asosoft.KurdishSort(myList))
["ئاو", "ئەو", "ڕەنگ", "فڵان", "ڤەژین", "یەک"]

or using your custom order:

>>> inputList = ["یەک", "ڕەنگ", "ئەو", "ئاو", "ڤەژین", "فڵان"]
>>> inputOrder = list("ئءاآأإبپتثجچحخدڎڊذرڕزژسشصضطظعغفڤقكکگڴلڵمنوۆۊۉۋهھەیێ")
>>> print(asosoft.CustomSort(inputList, inputOrder))
["ئاو", "ئەو", "ڕەنگ", "فڵان", "ڤەژین", "یەک"]

Poem Meter Classifier

It classifies the meter of the input Kurdish poem typed in Arabic script. The lines of the poem should be seprated by new line char ('\n'). You can find Kurdish poems in https://books.vejin.net/.

>>> poem = "گەرچی تووشی ڕەنجەڕۆیی و حەسرەت و دەردم ئەمن\nقەت لەدەس ئەم چەرخە سپڵە نابەزم مەردم ئەمن\nئاشقی چاوی کەژاڵ و گەردنی پڕ \nخاڵ نیم\nئاشقی کێو و تەلان و بەندەن و بەردم ئەمن"
>>> classified = asosoft.ClassifyKurdishPoem(poem)
>>> print("Poem Type= " + classified.overalMeterType)
Quantitative/عەرووزی
>>> print("Poem Meter= " + classified.overalPattern)
فاعلاتن فاعلاتن فاعلاتن فاعلن

Metadata

Release files for asosoft 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for asosoft 0.2.0
File Size Uploaded Provenance
asosoft-0.2.0.tar.gz 32.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for asosoft 0.2.0
File Interpreter ABI Platform
asosoft-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 62.6 kB

Release files / asosoft-0.2.0.tar.gz

Download URL asosoft-0.2.0.tar.gz
Size 32.6 kB
Tags Source
SHA-256 checksum
How to use checksums
c241e331f87b2a2aa8147875e0f34e85505f5af4dfcbce6d7d5ce669897eba3b
BLAKE2b-256 checksum
How to use checksums
82ed96424fecf45143a99b9281731d06493f4a5c65b9b33e7c34aadd837fbb5a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.3

Release files / asosoft-0.2.0-py3-none-any.whl

Download URL asosoft-0.2.0-py3-none-any.whl
Size 30.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d53ab2418c73b084bb9e9dbc8c953e987aea8af5b9ef9a76191afe36a29434cc
BLAKE2b-256 checksum
How to use checksums
ef5d8996e5f58b8e121befdf87dba9d528a44dff6d7f7b76e0a1a65e6da1a64f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.3

Security for asosoft 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page