Z12820

{
    "Z1K1": "Z2",
    "Z2K1": {
        "Z1K1": "Z6",
        "Z6K1": "Z12820"
    },
    "Z2K2": {
        "Z1K1": "Z14",
        "Z14K1": "Z12818",
        "Z14K3": {
            "Z1K1": "Z16",
            "Z16K1": "Z610",
            "Z16K2": "def Z12818(Z12818K1):\n\t# Setup section of the function #\n    import re\n    import unicodedata\n\n    # These hexadecimal values are based on Unicode specification\n    vowel_range = [chr(char_pos) for char_pos in range(0x1b83, 0x1b89+1)]\n    consonant_range = [chr(char_pos) for char_pos in range(0x1b8a, 0x1ba0+1)] + [chr(char_pos) for char_pos in range(0x1bae, 0x1baf+1)]\n    number_range = [chr(char_pos) for char_pos in range(0x1bb0, 0x1bb9+1)]\n    vowel_signs = {\"\\u1ba4\": \"i\", \"\\u1ba5\": \"u\", \"\\u1ba6\": \"é\", \"\\u1ba7\": \"o\", \"\\u1ba8\": \"e\", \"\\u1ba9\": \"eu\", \"\\u1baa\": \"\", \"\\u1bab\": \"\"}\n    final_consonants = {\"\\u1b80\": \"ng\", \"\\u1b81\": \"r\", \"\\u1b82\": \"h\"}\n    insert_consonants = {\"\\u1ba1\": \"y\", \"\\u1ba2\": \"r\", \"\\u1ba3\": \"l\"}\n\n    # Main section of the function #\n    res = Z12818K1\n    \n    # Find and replace all units that start with an independent vowel\n    for char in vowel_range:\n        unit_pattern = re.compile(f\"{char}[{*.join(final_consonants.keys())}]*\", re.UNICODE)\n        char_units = re.findall(unit_pattern, res)\n        # To handle overlapping units, sort the units by their lengths\n        # This way, the longer ones will be substituted first\n        char_units.sort(reverse=True, key=len)\n        \n        for unit in char_units:\n            # The Unicode name is \"SUNDANESE LETTER {base}\"; we just want the base part\n            base = unicodedata.name(char).split(\" \")[2].lower()\n            addition = \"\"\n            # Check whether there are any more characters\n            if len(unit) \u003C 2:\n                pass\n            elif unit[1] in final_consonants:\n                addition = final_consonants[unit[1]]\n                \n            res = res.replace(unit, base + addition)\n\n    # Find and replace all units that start with a consonant\n    for char in consonant_range:\n        unit_pattern = re.compile(f\"{char}[{*.join(final_consonants.keys())}{*.join(insert_consonants.keys())}{*.join(vowel_signs.keys())}]*\", re.UNICODE)\n        char_units = re.findall(unit_pattern, res)\n        # To handle overlapping units, sort the units by their lengths\n        # This way, the longer ones will be substituted first\n        char_units.sort(reverse=True, key=len)\n    \n        for unit in char_units:\n            # The Unicode name is \"SUNDANESE LETTER {base}A\"; we just want the base part\n            base = unicodedata.name(char).split(\" \")[2].rstrip(\"A\").lower()\n\n            # If there is only the base consonant in the unit, then by Sundanese script rules, it is followed by an \"a\"\n            if len(unit) \u003C 2:\n                addition = \"a\"\n            # The priority for appending letter to the base is additional consonant, vowel, then final consonant\n            elif unit[1] in insert_consonants:\n                addition = insert_consonants[unit[1]]\n                \n                # If there are no more characters,\n                # then by Sundanese script rules, the vowel for the syllable is \"a\"\n                if len(unit) \u003C 3:\n                    addition += \"a\"\n                elif unit[2] in vowel_signs:\n                    addition += vowel_signs[unit[2]]\n                    # Check whether there are any more characters\n                    if len(unit) \u003C 4:\n                        pass\n                    elif unit[3] in final_consonants:\n                        addition += final_consonants[unit[3]]\n\n                # If there is no vowel sign,\n                # then by Sundanese script rules, the vowel for the syllable is \"a\"\n                else:\n                    addition += \"a\"\n                    # Check whether there are any more characters\n                    if len(unit) \u003C 3:\n                        pass\n                    elif unit[2] in final_consonants:\n                        addition += final_consonants[unit[2]]\n\n            elif unit[1] in vowel_signs:\n                addition = vowel_signs[unit[1]]\n                # Check whether there are any more characters\n                if len(unit) \u003C 3:\n                    pass\n                elif unit[2] in final_consonants:\n                    addition += final_consonants[unit[2]]\n            else:\n                addition = \"a\"\n                # Check whether there are any more characters\n                if len(unit) \u003C 2:\n                    pass\n                elif unit[1] in final_consonants:\n                    addition += final_consonants[unit[1]]\n\n            res = res.replace(unit, base + addition)\n\n    # Find and replace all numbers that follow the proper grammar\n    number_pattern = re.compile(f\"\\|[{''.join(number_range)}]+\\|\", re.UNICODE)\n    found_numbers = re.findall(number_pattern, res)\n    for number in found_numbers:\n        latin_number = \"\"\n        for char in number.strip(\"|\"):\n            # Every Sundanese number can be converted to its Latin counterpart by extracting its last hex digit\n            latin_number += f\"{ord(char) % 0x1bb0}\"\n        res = res.replace(number, latin_number)\n\n    return res"
        }
    },
    "Z2K3": {
        "Z1K1": "Z12",
        "Z12K1": [
            "Z11",
            {
                "Z1K1": "Z11",
                "Z11K1": "Z1078",
                "Z11K2": "aksara Sunda ke Latin, Python"
            },
            {
                "Z1K1": "Z11",
                "Z11K1": "Z1002",
                "Z11K2": "Sundanese script to Latin, python"
            },
            {
                "Z1K1": "Z11",
                "Z11K1": "Z1430",
                "Z11K2": "Sudanesisch in Lateinisch in Python"
            }
        ]
    },
    "Z2K4": {
        "Z1K1": "Z32",
        "Z32K1": [
            "Z31",
            {
                "Z1K1": "Z31",
                "Z31K1": "Z1078",
                "Z31K2": [
                    "Z6",
                    "transliterasi aksara Sunda, Python"
                ]
            }
        ]
    },
    "Z2K5": {
        "Z1K1": "Z12",
        "Z12K1": [
            "Z11"
        ]
    }
}