Package: asosoft
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 poemHow to use?Python version: Python 3.11+Install package using pip:pip install asosoftImport package in your py file:importasosoftDevelopmentAsoSoft Library is developed and maintained by Aso Mahmudi.
AsoSoft Library is written in C# (.NET 6).Grapheme-to-Phoneme (G2P) converter and TransliterationThis function is based on the study "Automated Grapheme-to-Phoneme Conversion for Central Kurdish based on Optimality Theory".Kurdish G2P converterConverts Central Kurdish text in standard Arabic script intosyllabified phonemicLatin 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ˈtinTransliterationArabic script into Hawar Latin script (ح‌غ‌ڕڵ→ḧẍřł):>>>print(asosoft.Ar2La("گیرۆدەی خاڵی ڕەشتە؛ گوێت لە نەغمەی تویوورە؟"))gîrodeyxałîřeşte;gwêtleneẍmeytuyûre?Arabic script into the Latin script suggested by Dr. Feryad Fazil Omar:>>>print(asosoft.Ar2LaF("گیرۆدەی خاڵی ڕەشتە؛ گوێت لە نەغمەی تویوورە؟"))gîrodeyxaḻîṟeşte;gwêtlenex̱meytuyûre?Arabic script into simplified (ح‌غ‌ڕڵ→hxrl) Hawar Latin script:>>>print(asosoft.Ar2LaSimple("گیرۆدەی خاڵی ڕەشتە؛ گوێت لە نەغمەی تویوورە؟"))gîrodeyxalîreşte;gwêtlenexmeytuyû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·wuro̞ʒbujnbagɪ·ɾɪft.dɪ·ɾɛ·ʒijdi·wä·ɾa·kagɪɾ·tɪnKurdish Text NormalizerSeveral functions needed for Central Kurdish text normalization:Normalize KurdishTwo 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 spacesremoving Unicode control characterAdditional Unicode Correctionsreplacing special Arabic math signs with corresponding Latin charactersreplacing 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 listsPrivate Use Area (U+E000 to U+F8FF) with White Square characterStandardizing and removing duplicated or unnecessary Zero-Width charactersremoving unnecessary Tatweels (U+0640)only for Central Kurdish:standardizing Kurdish characters: ە, هـ, ی, and کcorrecting miss-converted characters from non-Unicode fontsreplacing 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 UnicodeAliK2Unicodeconverts 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 UnicodeAliWeb2Unicodeconverts Kurdish text written in AliK fonts into Unicode standard. Ali-Web fonts:Malper, Malper Bold, Samik, Traditional, Traditional Bold>>>print(asosoft.AliWeb2Unicode("هةر جةرةيانصکي مصذووُيي کة أوو دةدا"))ھەرجەرەیانێکیمێژووییکەڕوودەداDylan to UnicodeDylan2Unicodeconverts Kurdish text written in Dylan fonts (developed by Dylan Saleh atKurdSoftin 2001) into Unicode standard.>>>print(asosoft.Dylan2Unicode("لثكؤلثنةران بؤيان دةركةوتووة كة دةتوانث بؤ لةش بةكةصك بث"))لێکۆلێنەرانبۆیاندەرکەوتووەکەدەتوانێبۆلەشبەکەڵکبێZarnegar to UnicodeZarnegar2Unicodeconverts Kurdish text written in Zarnegar word processor (developed bySinaSoftwith RDF converter byNoorSoft) and into Unicode standard.>>>print(asosoft.Zarnegar2Unicode("بلٌيٌين و بگه‌رٍيٌين بوٌ هه‌لاٌلٌه‌ى سىٌيه‌مى فه‌لسه‌فه"))بڵێینوبگەڕێینبۆهەڵاڵەیسێیەمیفەلسەفەNormalizePunctuationsNormalizePunctuationscorrects spaces before and after of the punctuations. WhenseprateAllPunctuationsis true,>>>print(asosoft.NormalizePunctuations("دەقی«کوردی » و ڕێنووس ،((خاڵبەندی )) چۆنە ؟",false))دەقی«کوردی»وڕێنووس،«خاڵبەندی»چۆنە؟Trim LineTrim starting and ending white spaces (including zero width spaces) of line,TrimLine>>>print(TrimLine("   دەق\u200c"))دەقReplace Html EntitiesReplaceHtmlEntityreplaces HTML Entities with single Unicode characters (e.g. "é" with "é"). It is useful in web crawled corpora.>>>print(asosoft.ReplaceHtmlEntity("ئێوە &quot;دەق&quot; لە زمانی &lt;کوردی&gt; دەنووسن"))ئێوە"دەق"بەزمانی<کوردی>دەنووسنReplace URLs and emailsReplaceUrlEmailreplaces URLs and emails with a certain word. It improves language models.Unify NumeralsUnifyNumeralsunifies numeral characters into desired numeral type fromen(0123456789) orar(٠١٢٣٤٥٦٧٨٩)>>>print(asosoft.UnifyNumerals("ژمارەکانی ٤٥٦ و ۴۵۶ و 456","en"))ژمارەکانی456و456و456Seperate Digits from wordsSeperateDigitsadd 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 ReplacmentWord2WordReplacementapplies a "string to string" replacement dictionary on the text. It replaces the full-matched words not a part of them.>>>dict={"مال":"ماڵ","سلاو":"سڵاو"}>>>print(asosoft.Word2WordReplacement("مال، نووری مالیکی",dict))ماڵ،نووریمالیکیCharacter to Character ReplacmentChar2CharReplacmentapplies a "char to char" replacement dictionary on the text. It uses as the final step needed for some non-Unicode systems.Kurdish Numeral converterIt 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 SortSorting 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 ClassifierIt 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 inhttps://books.vejin.net/.>>>poem="گەرچی تووشی ڕەنجەڕۆیی و حەسرەت و دەردم ئەمن\nقەت لەدەس ئەم چەرخە سپڵە نابەزم مەردم ئەمن\nئاشقی چاوی کەژاڵ و گەردنی پڕ\nخاڵ نیم\nئاشقی کێو و تەلان و بەندەن و بەردم ئەمن">>>classified=asosoft.ClassifyKurdishPoem(poem)>>>print("Poem Type= "+classified.overalMeterType)>>>print("Poem Meter= "+classified.overalPattern)