HeArBERT / preprocessing.py
aviadrom's picture
Create preprocessing.py
5178dd6
ARABIC_TO_HEBREW_LETTER_MAP = {
"ا": "א",
"ب": "ב",
"ج": "ג׳",
"غ": "ג",
"د": "ד",
"ذ": "דֿ",
"ه": "ה",
"ة": "ה׳",
"و": "ו",
"ز": "ז",
"ح": "ח",
"ط": "ט",
"ظ": "ט׳",
"ي": "י",
"ك": "כ",
"خ": "כ׳",
"ل": "ל",
"م": "מ",
"ن": "נ",
"س": "ס",
"ع": "ע",
"ف": "פ",
"ص": "צ",
"ض": "צ׳",
"ق": "ק",
"ر": "ר",
"ش": "ש",
"ت": "ת",
"ث": "ת׳",
"ء": "א",
"ئ": "י",
"ؤ": "ו",
"ى": "א",
"؟": "?",
"إ": "א",
"آ": "א",
"أ": "א",
}
def transliterate_arabic_to_hebrew(text):
assert isinstance(text, str), "Cannot transliterate non-string values"
result_chars = [ARABIC_TO_HEBREW_LETTER_MAP.get(c, c) for c in text]
return "".join(result_chars)