Z16206

{
    "Z1K1": "Z2",
    "Z2K1": {
        "Z1K1": "Z6",
        "Z6K1": "Z16206"
    },
    "Z2K2": {
        "Z1K1": "Z14",
        "Z14K1": "Z16184",
        "Z14K3": {
            "Z1K1": "Z16",
            "Z16K1": "Z610",
            "Z16K2": "def Z16184(Z16184K1):\r\n    \"\"\"\r\n    This function converts a number to its Standard Arabic representation.\r\n    It would definitely break for super large numbers which have no\r\n    corresponding representation. Add more elements to \"orders\"\r\n    if you want it to work for larger numbers (eventually you'll\r\n    get a stack overflow or timeout though).\r\n    \"\"\"\r\n    \r\n    if Z16184K1 == 0:\r\n        return \"صفر\"\r\n    if Z16184K1 \u003E999999999999999999999999999999999999999999999999999999999999999:\r\n        return Wikifunctions.Error(\"Z28307\",[str(Z16184K1),\"999999999999999999999999999999999999999999999999999999999999999\",\"ar-001\"])\r\n\r\n    AND = \" و\"\r\n    T_MARBOUTA = \"ة\"\r\n    DUAL_FORM = \"ان\"\r\n    FEM_PLURAL = \"ات\"\r\n    ACC_FORM = \"اً\"\r\n    units = [\"صفر\", \"واحد\", \"إثنان\", \"ثلاث\", \"أربع\", \"خمس\", \"ست\", \"سبع\", \"ثماني\", \"تسع\"]\r\n    teens = [\"عشرة\", \"أحد عشر\", \"إثنا عشر\", \"ثلاثة عشر\", \"أربعة عشر\", \"خمسة عشر\", \"ستة عشر\", \"سبعة عشر\", \"ثمانية عشر\", \"تسعة عشر\"]\r\n    tens = [\"\", \"عشرة\", \"عشرون\", \"ثلاثون\", \"أربعون\", \"خمسون\", \"ستون\", \"سبعون\", \"ثمانون\", \"تسعون\"]\r\n\r\n    hundred = \"مئة\"\r\n    two_hundreds = \"مئتان\"\r\n    \r\n    orders = [\"\",\"ألف\",\"مليون\",\"مليار\",\"تريليون\",\"كوادريليون\",\"كوينتيليون\",\"سيكستيليون\"\r\n             ,\"سيبتيليون\",\"أوكتيليون\",\"نونيليون\",\"ديسيليون\",\"دودشيليون\",\"تريدشيليون\",\"كواتوردشيليون\"\r\n             ,\"كويندشيليون\",\"سكسدشيليون\",\"سبتندشيليون\",\"أوكتودشيليون\",\"نوفمدشيليون\",\"فجنتليون\"]\r\n    \r\n    orders_plural = [\"\", \"آلاف\", \"ملايين\", \"ملايير\"]\r\n\r\n    def convert_number(n):\r\n        if n == 0:\r\n            return \"\"\r\n        elif n \u003C 3:\r\n            return units[n]\r\n        elif n \u003C 10:\r\n            return units[n]+T_MARBOUTA\r\n        elif n \u003C 20:\r\n            return teens[n - 10]\r\n        elif n \u003C 100:\r\n            if n % 10 == 0:\r\n                return tens[n // 10]\r\n            else:\r\n                if n % 10 \u003C 3:\r\n                    return units[n % 10] + AND + tens[n // 10]\r\n                return units[n % 10]+T_MARBOUTA + AND + tens[n // 10]\r\n        else: #elif n \u003C 1000:\r\n            if n % 100 == 0:\r\n                if n // 100 == 1:\r\n                    return hundred\r\n                elif n // 100 == 2:\r\n                    return two_hundreds\r\n                elif n // 100 == 8:\r\n                    return units[8][:-1]+\" \"+hundred\r\n                return units[n // 100]+\" \"+hundred\r\n            else:\r\n                if n // 100 == 1:\r\n                    return hundred + AND + convert_number(n % 100)\r\n                elif n // 100 == 2:\r\n                    return two_hundreds + AND + convert_number(n % 100)\r\n                elif n // 100 == 8:\r\n                    return units[8][:-1]+\" \"+hundred + AND + convert_number(n % 100)\r\n                return units[n // 100]+\" \"+hundred + AND + convert_number(n % 100)\r\n\r\n    def convert_large_number(n):\r\n        if n \u003C 1000:\r\n            return convert_number(n)\r\n        \r\n        for order in range(len(orders) - 1, 0, -1):\r\n            order_value = 10 ** (order * 3)\r\n            if n \u003E= order_value:\r\n                major_part = n // order_value\r\n                remainder = n % order_value\r\n                major_part_str = convert_number(major_part)\r\n                remainder_str = convert_large_number(remainder)\r\n                order_name = orders[order]\r\n\r\n                if major_part == 1:\r\n                    return (orders[order] + (AND + remainder_str if remainder else \"\")).strip()\r\n                elif major_part == 2:\r\n                    return (orders[order]+ DUAL_FORM + \" \" + (AND + remainder_str if remainder else \"\")).strip()\r\n                elif major_part % 100 \u003C 11:\r\n                    if order \u003C 4:\r\n                        return (major_part_str + \" \" + orders_plural[order] + (AND + remainder_str if remainder else \"\")).strip()\r\n                    return (major_part_str + \" \" + orders[order]+FEM_PLURAL + (AND + remainder_str if remainder else \"\")).strip()\r\n                \r\n                return (major_part_str + \" \" + order_name+ACC_FORM + (AND + remainder_str if remainder else \"\")).strip()\r\n                \r\n    return convert_large_number(Z16184K1)"
        }
    },
    "Z2K3": {
        "Z1K1": "Z12",
        "Z12K1": [
            "Z11",
            {
                "Z1K1": "Z11",
                "Z11K1": "Z1002",
                "Z11K2": "Standard Arabic cardinal, python"
            },
            {
                "Z1K1": "Z11",
                "Z11K1": "Z1004",
                "Z11K2": "cardinal en arabe standard, en Python"
            },
            {
                "Z1K1": "Z11",
                "Z11K1": "Z1430",
                "Z11K2": "Arabische Kardinalzahl in Python"
            }
        ]
    },
    "Z2K4": {
        "Z1K1": "Z32",
        "Z32K1": [
            "Z31"
        ]
    },
    "Z2K5": {
        "Z1K1": "Z12",
        "Z12K1": [
            "Z11",
            {
                "Z1K1": "Z11",
                "Z11K1": "Z1002",
                "Z11K2": "NB: for the number 11 the masculine form is used, not the feminine form إحدى عشر for the sake of simplification, otherwise an additional parameter with values M/F can be added.\nNB 2: the implementation does not take into consideration case endings and variations of words when a number is used in a sentence. It outputs the number as it would likely be read alone out of context."
            },
            {
                "Z1K1": "Z11",
                "Z11K1": "Z1430",
                "Z11K2": "Python-Implementierung der Funktion zur Ausgabe der Arabischen Kardinalzahl"
            }
        ]
    }
}