Z26080

{
    "Z1K1": "Z2",
    "Z2K1": {
        "Z1K1": "Z6",
        "Z6K1": "Z26080"
    },
    "Z2K2": {
        "Z1K1": "Z14",
        "Z14K1": "Z26076",
        "Z14K3": {
            "Z1K1": "Z16",
            "Z16K1": "Z600",
            "Z16K2": "function Z26076( Z26076K1 ) {\n\tvar input=Z26076K1;\n\tconst separators=[\" \",\"\\t\",\"/\",\"\\\\\",\"'\",'\"',\"|\"];\n\tconst prefOptions=[\"yemd\",\"eymd\",\"dmye\",\"dmey\",\"mdye\",\"mdey\",\"yedm\",\"eydm\",];\n\n\tfunction languageSpecificOptions(){\n\n\t\tdefineLiterals({\n\t\t\tad:1n,\n\t\t\tbc:-1n,\n\t\t\tbce:-1n,\n\t\t\tce:1n,\n\t\t},ERA);\n\t\t\n\t\t/// ADD HERE THE LANGUAGE-SPECIFIC OPTIONS\n\t\tdefineLiterals({\n\t\t\t公元:1n,\n\t\t\t公元前:-1n,\n\t\t\t前:-1n,\n\t\t},ERA);\n\t\t\n\t\t\n\t\tdefineLiteralFunction(function(t,i){\n\t\t\tlet yearKeys = ['零','一','二','三','四','五','六','七','八','九'];\n\t\t\tlet otherYearKeys  = ['〇'];\n\t\t\tlet arabYear=\"\";\n\t\t\tlet nTokens=0;\n\t\t\tfor(;i\u003Ct.length; ++i){\n\t\t\t\tlet c1=yearKeys.findIndex((a)=\u003Ea==t[i]);\n\t\t\t\tlet c2=otherYearKeys.findIndex((a)=\u003Ea==t[i]);\n\t\t\t\tif (c1==-1 \u0026\u0026 c2==-1){\n\t\t\t\t\tif (nTokens==0) return null;\n\t\t\t\t\treturn [BigInt(arabYear),nTokens];\n\t\t\t\t}\n\t\t\t\tnTokens++;\n\t\t\t\tif (c1==-1){\n\t\t\t\t\tarabYear+=c2;\n\t\t\t\t}\n\t\t\t\telse if (c2==-1){\n\t\t\t\t\tarabYear+=c1;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tif (nTokens==0) return null;\n\t\t\treturn [BigInt(arabYear),nTokens];\n\t\t},YEAR)\n\t\t\n\t\tdefineLiterals({\n\t\t\t一:0n,\n\t\t\t二:1n,\n\t\t\t三:2n,\n\t\t\t四:3n,\n\t\t\t五:4n,\n\t\t\t六:5n,\n\t\t\t七:6n,\n\t\t\t八:7n,\n\t\t\t九:8n,\n\t\t\t十:9n,\n\t\t\t十一:10n,\n\t\t\t十二:11n,\n\t\t},MONTH);\n\t\t\n\t\tdefineLiterals({\n\t\t\t一:1n,\n\t\t\t二:2n,\n\t\t\t三:3n,\n\t\t\t四:4n,\n\t\t\t五:5n,\n\t\t\t六:6n,\n\t\t\t七:7n,\n\t\t\t八:8n,\n\t\t\t九:9n,\n\t\t\t十:10n,\n\t\t\t十一:11n,\n\t\t\t十二:12n,\n\t\t\t十三:13n,\n\t\t\t十四:14n,\n\t\t\t十五:15n,\n\t\t\t十六:16n,\n\t\t\t十七:17n,\n\t\t\t十八:18n,\n\t\t\t十九:19n,\n\t\t\t二十:20n,\n\t\t\t二十一:21n,\n\t\t\t二十二:22n,\n\t\t\t二十三:23n,\n\t\t\t二十四:24n,\n\t\t\t二十五:25n,\n\t\t\t二十六:26n,\n\t\t\t二十七:27n,\n\t\t\t二十八:28n,\n\t\t\t二十九:29n,\n\t\t\t三十:30n,\n\t\t\t三十一:31n,\n\t\t\t廿:20n,\n\t\t\t廿一:21n,\n\t\t\t廿二:22n,\n\t\t\t廿三:23n,\n\t\t\t廿四:24n,\n\t\t\t廿五:25n,\n\t\t\t廿六:26n,\n\t\t\t廿七:27n,\n\t\t\t廿八:28n,\n\t\t\t廿九:29n,\n\t\t\t卅:30n,\n\t\t\t卅一:31n\n\t\t},DAY);\n\t\t\n\t\t\n\t\tdefineConstraint([\"年\"],YEAR, AFTER);\n\t\tdefineConstraint([\"月\"],MONTH, AFTER);\n\t\tdefineConstraint([\"日\",\"號\",\"号\"],DAY, AFTER);\t\t\n\t}\n\n\tconst DAY =0;\n\tconst MONTH=1;\n\tconst YEAR=2;\n\tconst ERA=3;\n\n\tconst BEFORE=10;\n\tconst AFTER=20;\n\tconst BEFORE_OR_AFTER=30;\n\n\tconst LENIENT=Symbol();\n\tconst NORMAL=Symbol();\n\tconst LETTER_BY_LETTER=Symbol();\n\n\tfunction defineLiterals(literals,meaning,compMode=LETTER_BY_LETTER, forced=false){\n\t\tlet bestGuess=null;\n\t\tconst compFunc= compMode==LENIENT ? lenientComp : lessLenientComp;\n\t\tfor (let m in literals){\n\t\t\tlet target=m.split(\" \");\n\t\t\tlet ok=true;\n\t\t\tfor (let t=0; t\u003Ctarget.length; ++t){\n\t\t\t\tif (elements[iAtt+t]==undefined || !compFunc(elements[iAtt+t],target[t])){\n\t\t\t\t\tok=false;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (ok){\n\t\t\t\tif (bestGuess == null || bestGuess[1]\u003Ctarget.length){\n\t\t\t\t\tbestGuess = [literals[m],target.length];\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (compMode==LETTER_BY_LETTER ){\n\t\t\t\tlet target=m.split(\"\");\n\t\t\t\ttarget.filter((l)=\u003El!=\" \");\n\t\t\t\tlet ok=true;\n\t\t\t\tfor (let t=0; t\u003Ctarget.length; ++t){\n\t\t\t\t\tif (elements[iAtt+t]==undefined || !compFunc(elements[iAtt+t],target[t])){\n\t\t\t\t\t\tok=false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (ok){\n\t\t\t\t\tif (bestGuess == null || bestGuess[1]\u003Ctarget.length){\n\t\t\t\t\t\tbestGuess = [literals[m],target.length];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\t\tif (bestGuess==null){\n\t\t\treturn false;\n\t\t}\n\n\t\tif (typeof(meaning)==\"number\"){\n\t\t\tmeaning=[meaning];\n\t\t}\n\t\tfor (let m of meaning){\n\t\t\tswitch(m){\n\t\t\t\tcase 0: _day=bestGuess[0]; break;\n\t\t\t\tcase 1: _month=bestGuess[0]; break;\n\t\t\t\tcase 2: _year=bestGuess[0]; break;\n\t\t\t\tcase 3: _era=bestGuess[0]; break;\n\t\t\t}\n\t\t}\n\t\t_nSteps=Math.max(bestGuess[1], _nSteps);\n\t\tif (forced){\n\t\t\t_forced=meaning;\n\t\t}\n\t\treturn true;\n\n\t}\n\tfunction defineLiteralFunction(f,meaning, forced=false){\n\t\tlet bestGuess=f(elements,iAtt);\n\t\tif (bestGuess==null){\n\t\t\treturn false;\n\t\t}\n\n\t\tif (typeof(meaning)==\"number\"){\n\t\t\tmeaning=[meaning];\n\t\t}\n\t\tfor (let m of meaning){\n\t\t\tswitch(m){\n\t\t\t\tcase 0: _day=bestGuess[0]; break;\n\t\t\t\tcase 1: _month=bestGuess[0]; break;\n\t\t\t\tcase 2: _year=bestGuess[0]; break;\n\t\t\t\tcase 3: _era=bestGuess[0]; break;\n\t\t\t}\n\t\t}\n\t\t_nSteps=Math.max(bestGuess[1], _nSteps);\n\t\tif (forced){\n\t\t\t_forced=meaning;\n\t\t}\n\t\treturn true;\n\t}\n\tfunction defineConstraint(literals, meaning, position, compMode=LETTER_BY_LETTER){\n\n\t\tlet bestGuess=null;\n\t\tconst compFunc= compMode==LENIENT ? lenientComp : lessLenientComp;\n\t\tfor (let m of literals){\n\t\t\tlet target=m.split(\" \");\n\t\t\tlet ok=true;\n\t\t\tfor (let t=0; t\u003Ctarget.length; ++t){\n\t\t\t\tif (elements[iAtt+t]==undefined || !compFunc(elements[iAtt+t],target[t])){\n\t\t\t\t\tok=false;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (ok){\n\t\t\t\tif (bestGuess == null || bestGuess\u003Ctarget.length){\n\t\t\t\t\tbestGuess = target.length;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (compMode==LETTER_BY_LETTER ){\n\t\t\t\tlet target=m.split(\"\");\n\t\t\t\ttarget.filter((l)=\u003El!=\" \");\n\t\t\t\tlet ok=true;\n\t\t\t\tfor (let t=0; t\u003Ctarget.length; ++t){\n\t\t\t\t\tif (elements[iAtt+t]==undefined || !compFunc(elements[iAtt+t],target[t])){\n\t\t\t\t\t\tok=false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (ok){\n\t\t\t\t\tif (bestGuess == null || bestGuess\u003Ctarget.length){\n\t\t\t\t\t\tbestGuess = target.length;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\t\tif (bestGuess==null){\n\t\t\treturn false;\n\t\t}\n\t\t\n\n\t\tif (typeof(meaning)==\"number\"){\n\t\t\tmeaning=[meaning];\n\t\t}\n\t\t\n\t\t_constraintsList.push({pos:possibilities.length, meaning:meaning, type: position});\n\n\t\t_nSteps=Math.max(bestGuess, _nSteps);\n\t\t_isToBeIgnored=true;\n\t\treturn true;\n\t}\n\tfunction defineConstraintFunction(f,meaning,position){\n\n\t\tlet bestGuess=f(elements,iAtt);\n\t\tif (bestGuess==null){\n\t\t\treturn false;\n\t\t}\n\n\t\tif (typeof(meaning)==\"number\"){\n\t\t\tmeaning=[meaning];\n\t\t}\n\t\t_constraintsList.push({pos:possibilities.length, meaning:meaning, type: position});\n\t\t_nSteps=Math.max(bestGuess, _nSteps);\n\t\t_isToBeIgnored=true;\n\t\treturn true;\n\t}\n\n\tfunction lenientComp(a,b){\n\t\ta=a.toLowerCase().replaceAll(/,|\\.|;|:/g,\"\");\n\t\tb=b.toLowerCase();\n\t\tif (a==\"\") return false;\n\t\treturn a==b.substring(0,a.length);\n\t}\n\n\tfunction lessLenientComp(a,b){\n\t\ta=a.toLowerCase().replaceAll(/,|\\.|;|:/g,\"\");\n\t\tb=b.toLowerCase();\n\t\tif (a==\"\") return false;\n\t\treturn a==b;\n\t}\n\n\tfunction extractNumber(s){\n\t\tlet res=/-?[0-9]+/.exec(s);\n\t\tif (res!=null){\n\t\t\treturn BigInt(res);\n\t\t}\n\t\treturn null;\n\t}\n\n\n\tfunction forceToYear(s){\n\t\tlet res=(/-?\\+?[0-9]+/.exec(s))?.[0];\n\t\tif (res==null){\n\t\t\treturn false;\n\t\t}\n\t\t//Wikifunctions.Debug(res);\n\t\tif (res.length\u003E2) return true;\n\t\tif (res[0]==\"-\" || res[0]==\"+\") return true;\n\t\treturn false;\n\t}\n\n\t\n\n\tinput=input.replaceAll(/-|—|‒|–|—|⸺|⸺/g,\"-\");\n\n\tvar isoRegex=/(\\d{4}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d\\.\\d+)|(\\d{4}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d)|(\\d{4}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d)/;\n\tif (isoRegex.exec(input)){\n\t\tinput=input.split(\"T\")[0];\n\t\tvar list=input.split(/(?\u003C=.)-(?=.)/);\n\t\t//Wikifunctions.Debug(list);\n\t\treturn {\n\t\t\tK1: BigInt(list[0]),\n\t\t\tK2: list[1]-1,\n\t\t\tK3: list[2]\n\t\t};\n\t}\n\n\tvar elements=[\"\"];\n\tfor (let i=0; i\u003Cinput.length;){\n\t\tlet s=separators.find((v)=\u003E input.substring(i,i+v.length)==v);\n\t\tif (s!==undefined){\n\t\t\tif(elements[elements.length-1]!=\"\")\n\t\t\t\telements.push(\"\");\n\t\t\ti+=s.length;\n\t\t\tcontinue;\n\t\t}\n\t\telements[elements.length-1]+=input[i++];\n\t}\n\tif(elements[elements.length-1]==\"\") elements.pop();\n\n\n\tlet elSeparato=[];\n\tfor (let i=0; i\u003Celements.length; ++i){\n\t\tfor (let e of elements[i].matchAll(/((?:(?\u003C=^|\\s)[\\-\\+])?[0-9]+)?(?:\\-?([^0-9\\-\\u4e00-\\u9fa5]+))?([\\u4e00-\\u9fa5])?/g)){\n\t\t\telSeparato.push(e.splice(1))\n\t\t}\n\t\t// elSeparato.push(/-?\\+?[0-9]+/.exec(elements[i]));\n\t\t// elSeparato.push(elements[i].split(/-?\\+?[0-9]+/));\n\t}\n\telSeparato=elSeparato.flat();\n\telements=elSeparato.filter((v)=\u003E(v!=null \u0026\u0026 v!=\"\"));\n\n\t// Wikifunctions.Debug(\"elements:\");\n\t// Wikifunctions.Debug(elements);\n\n\t//Order of possibilities: dmye\n\tvar possibilities=[];\n\n\tvar _constraintsList=[];\n\tvar _nSteps=1;\n\n\tfor(var iAtt=0; iAtt\u003Celements.length; iAtt+=_nSteps){\n\t\t_nSteps=1;\n\t\tlet n=extractNumber(elements[iAtt]);\n\t\tvar _day=null;\n\t\tvar _month=null;\n\t\tvar _year=null;\n\t\tvar _era=null;\n\t\tvar _forced=null;\n\t\tvar _isToBeIgnored=false;\n\n\t\t//////////\n\n\t\tlanguageSpecificOptions();\n\n\t\tlet p=[];\n\t\t//day\n\t\tp.push(_day ?? ((n!=null \u0026\u0026 n\u003E0n \u0026\u0026 n\u003C=31n) ? n : null));\n\t\t//month\n\t\tp.push(_month ?? ((n!=null \u0026\u0026 n\u003E0n \u0026\u0026 n\u003C=12n) ? n-1n :null));\n\t\t//year\n\t\tp.push(_year ?? n);\n\t\t//epoch\n\t\tp.push(_era);\n\n\t\tif (_forced!=null){\n\t\t\tfor (let j=0; j\u003C=3; ++j){\n\t\t\t\tif (_forced.find((v)=\u003E(v==j)) == undefined){\n\t\t\t\t\tp[j]=null;\t\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (forceToYear(elements[iAtt])){\n\t\t\tp[0]=null;\n\t\t\tp[1]=null;\n\t\t\tp[3]=null;\n\t\t}\n\n\t\tif (!_isToBeIgnored)\n\t\t\tpossibilities.push(p);\n\t}\n\t\n\n\tif (_constraintsList.length\u003E0){\n\t\tfor (let pAtt=0; pAtt\u003C possibilities.length; ++pAtt){\n\t\t\tfor (let c of _constraintsList){\n\t\t\t\tif ((c.type==AFTER \u0026\u0026 pAtt!=c.pos-1) ||\n\t\t\t\t    (c.type==BEFORE \u0026\u0026 pAtt!=c.pos) ||\n\t\t\t\t    (c.type==BEFORE_OR_AFTER \u0026\u0026 pAtt!=c.pos-1 \u0026\u0026 pAtt!=c.pos)){\n\t\t\t\t\tfor(let m of c.meaning){\n\t\t\t\t\t\tpossibilities[pAtt][m]=null;\t\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tpossibilities=possibilities.filter((v)=\u003E(v[0]!=null || v[1]!=null || v[2]!=null || v[3]!=null));\n\n\tfor (let i=0; i\u003CprefOptions.length; ++i){\n\t\tlet actPref=prefOptions[i];\n\t\tlet d,m,y,e;\n\t\tif (possibilities.length\u003C4) actPref=actPref.replace(\"e\",\"\");\n\t\tif (possibilities.length\u003C3) actPref=actPref.replace(\"y\",\"\");\n\t\tfor (let j=0; j\u003CactPref.length; ++j){\n\t\t\tswitch(actPref[j]){\n\t\t\t\tcase \"d\":{\n\t\t\t\t\td=possibilities[j]?.[0]; break;\n\t\t\t\t}\n\t\t\t\tcase \"m\":{\n\t\t\t\t\tm=possibilities[j]?.[1]; break;\n\t\t\t\t}\n\t\t\t\tcase \"y\":{\n\t\t\t\t\ty=possibilities[j]?.[2]; break;\n\t\t\t\t}\n\t\t\t\tcase \"e\":{\n\t\t\t\t\te=possibilities[j]?.[3];break;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (d!=null \u0026\u0026 m!=null \u0026\u0026 (possibilities.length\u003C3 || y!=null)){\n\t\t\treturn{\n\t\t\t\tK2: Number(d),\n\t\t\t\tK1: Number(m),\n\t\t\t};\n\t\t}\n\t}\n\n}"
        }
    },
    "Z2K3": {
        "Z1K1": "Z12",
        "Z12K1": [
            "Z11",
            {
                "Z1K1": "Z11",
                "Z11K1": "Z1787",
                "Z11K2": "leggi giorno di anno romano, cinese, js"
            },
            {
                "Z1K1": "Z11",
                "Z11K1": "Z1002",
                "Z11K2": "read Day of Roman year, Chinese, javascript"
            }
        ]
    },
    "Z2K4": {
        "Z1K1": "Z32",
        "Z32K1": [
            "Z31"
        ]
    },
    "Z2K5": {
        "Z1K1": "Z12",
        "Z12K1": [
            "Z11"
        ]
    }
}