sinatools.utils.text_transliteration

sinatools.utils.text_transliteration.perform_transliteration(text, schema)

This method takes a text and a schema as input and returns a tuple of two values: the transliteration of the text based on the given schema and a flag indicating whether all characters in the text were transliterated or not.

Parameters
  • text (str) – The input text to be transliterated.

  • schema (str) – The transliteration schema to be used. Should be either bw2ar to transliterate Buckwalter-encoded Arabic text to Arabic script, or ar2bw to transliterate Arabic script to Buckwalter-encoded Arabic text.

Returns

A tuple of two values: - The transliterated text based on the given schema. - A boolean flag indicating whether all characters in the input text were successfully transliterated or not.

Return type

tuple

Example:

from sinatools.utils import text_transliteration

print(text_transliteration.perform_transliteration("مُحَمَدٌ نَـشِيْطٌـ1"  , "ar2bw"))
print(text_transliteration.perform_transliteration("muHamadN"  , "bw2ar"))
print(text_transliteration.perform_transliteration("شَنُعُ۪ـ1"  , "ar2bw"))
print(text_transliteration.perform_transliteration("$aw~aH_2"  , "bw2ar"))

#output
('muHamadN na_$iyoTN_1', True)
('مُحَمَدٌ', True)
('$anuE-u_1', True)
('شَوَّح 2', True)