Z30181

{
    "Z1K1": "Z2",
    "Z2K1": {
        "Z1K1": "Z6",
        "Z6K1": "Z30181"
    },
    "Z2K2": {
        "Z1K1": "Z14",
        "Z14K1": "Z30177",
        "Z14K3": {
            "Z1K1": "Z16",
            "Z16K1": "Z600",
            "Z16K2": "function Z30177(Z30177K1, Z30177K2, Z30177K3, Z30177K4) {\n\tfunction tipo(o){\n\t\to=o.Z1K1;\n\t\twhile(o.Z1K1?.Z1K1===\"Z4\"){\n\t\t\to=o.Z1K1.Z4K1;\n\t\t}\n\t\treturn o.Z9K1;\n\t}\n\tconst connItemPIDs=[\"P5137\",\"P9970\", \"P6271\"];\n\tfunction relevantSenses( Z27292K1, QIDs ) {\n\t\tconst linkProperties=connItemPIDs;\n\t\tlet ret=[];\n\t\tfor (let s of Z27292K1.Z6005K6){\n\t\t\tfor (let c of s.Z6006K3){\n\t\t\t\tif (linkProperties.find((a)=\u003Ea===c.Z6003K2.Z6092K1)!=undefined \u0026\u0026 QIDs.findIndex(i=\u003Ei===c.Z6003K3.Z6091K1)!==-1){\n\t\t\t\t\tret.push( [s,QIDs.findIndex(i=\u003Ei===c.Z6003K3.Z6091K1)]);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn ret;\n\t}\n\tfunction etichettaElemento( Z24114K1, Z24114K2 ) {\n\t\tconst Z11s = Z24114K1.Z6001K2.Z12K1;\n\t\tfor (const Z60 of Z24114K2) {\n\t\t\tfor (const Z11 of Z11s) {\n\t\t\t\tif (Z11.Z11K1.Z60K1 == Z60.Z60K1) {\n\t\t\t\t\treturn (Z11.Z11K2[0].toLocaleUpperCase(Z11.Z11K1.Z60K1)+Z11.Z11K2.slice(1));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfunction etichettaLessema( Z24114K1, Z24114K2 ) {\n\t\tconst Z11s = Z24114K1.Z6005K2.Z12K1;\n\t\tfor (const Z60 of Z24114K2) {\n\t\t\tfor (const Z11 of Z11s) {\n\t\t\t\tif (Z11.Z11K1.Z60K1 == Z60.Z60K1) {\n\t\t\t\t\treturn (Z11.Z11K2[0].toLocaleUpperCase(Z11.Z11K1.Z60K1)+Z11.Z11K2.slice(1));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfunction miglioriLessemi( Z27332K1, Z27332K2, nomeItem ) {\n\t\tconst connItemPIDs=[\"P5137\",\"P9970\", \"P6271\"];\n\t\tfunction relevantSense( Z27292K1, Z27292K2 ) {\n\t\t\tconst linkProperties=connItemPIDs;\n\t\t\tfor (let s of Z27292K1.Z6005K6){\n\t\t\t\tfor (let c of s.Z6006K3){\n\t\t\t\t\tif (linkProperties.find((a)=\u003Ea===c.Z6003K2.Z6092K1)!=undefined \u0026\u0026 c.Z6003K3.Z6091K1===Z27292K2.Z6091K1){\n\t\t\t\t\t\treturn [s,c.Z6003K2.Z6092K1];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn [null,null];\n\t\t}\n\t\t\n\t\tfor (let i=0; i\u003CZ27332K1.length; ++i){\n\t\t\tif (relevantSense(Z27332K1[i],Z27332K2)[0]===null){\n\t\t\t\tWikifunctions.Error(\"Z28258\", [Z27332K1[i].Z6005K1.Z6095K1, //lexeme LID\n\t\t\t\t\t\t\t\t\"\",Z27332K2.Z6091K1, //item QID\n\t\t\t\t\t\t\t\t\"Z27332K1[\"+(i+1)+\"]\", \"\",\"Z27332K2\"]);\n\t\t\t}\n\t\t}\n\t\t\n\t\tfunction valuesOfStatementOfSense(s,p){\n\t\t\t//p is a list\n\t\t\tlet retList=[]\n\t\t\tfor (let c of s.Z6006K3){\n\t\t\t\tif (p.find((a)=\u003Ea===c.Z6003K2.Z6092K1) != undefined){\n\t\t\t\t\tretList.push(c.Z6003K3.Z6091K1);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn retList;\n\t\t}\n\t\t\n\t\tfunction rankOfStatementOfSense(s,p){\n\t\t\t//p is a list\n\t\t\tfor (let c of s.Z6006K3){\n\t\t\t\tif (p.find((a)=\u003Ea===c.Z6003K2.Z6092K1) != undefined){\n\t\t\t\t\treturn c.Z6003K4.Z6040K1.Z9K1;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn null;\n\t\t}\n\t\t\n\t\tconst languageStylePIDs=[\"P6191\"];\n\t\t\n\t\tconst rankRank=[\"Z6043\",\"Z6042\",\"Z6041\"];\n\t\tconst styleRank=[\n\t\t\t\"Q184439\",\t\t//profanity\n\t\t\t\"Q1521634\",\t\t//vulgarism\n\t\t\t\"Q545779\",\t\t//pejorative\n\t\t\t\"Q83464\",\t\t//euphemism\n\t\t\t\"Q58233068\",\t//humorous\n\t\t\t\"Q58157328\",\t//rare\n\t\t\t\"Q901711\",\t\t//colloqual\n\t\t\t\"Q181970\",\t\t//archaism\n\t\t\t\"Q57495609\",\t//outdated\n\t\t\t\"Q110983878\",\t//idiomatic\n\t\t\t\"Q130989\",\t\t//neologism\n\t\t\t];\n\t\t\n\t\tconst worstLexicalCategoryRank=[\n\t\t\t\"Q201322\",\t\t//prefix\n\t\t\t\"Q102047\",\t\t//suffix\n\t\t\t\"Q134830\",\t\t//prefix\n\t\t\t\"Q62155\",\t\t//affix\n\t\t\t];\n\t\tconst bestLexicalCategoryRank={\n\t\t\t//item for this sense\n\t\t\tP5137:[\"Q380057\",\"Q24905\",\"Q34698\",\"Q147276\",\"Q1084\"],\n\t\t\t//predicate for\n\t\t\tP9970:[\"Q24905\"],\n\t\t\t//denonym of\n\t\t\tP6271:[\"Q147276\",\"Q1084\"],\n\t\t\t};\n\t\t\n\t\tfunction compare(a,b){\n\t\t\tconst [sa,linkingPredicatea]=relevantSense(a,Z27332K2);\n\t\t\tconst [sb,linkingPredicateb]=relevantSense(b,Z27332K2);\n\t\t\t\n\t\t\t//ranks\n\t\t\tconst ra=rankOfStatementOfSense(sa,connItemPIDs);\n\t\t\tconst rb=rankOfStatementOfSense(sb,connItemPIDs);\n\t\t\t\n\t\t\tif (ra!==rb){\n\t\t\t\treturn rankRank.findIndex((a)=\u003Ea===ra) \u003C rankRank.findIndex((a)=\u003Ea===rb) ? 1 : -1;\n\t\t\t}\n\t\t\t\n\t\t\t//language style\n\t\t\tconst lsa=valuesOfStatementOfSense(sa,languageStylePIDs);\n\t\t\tconst lsb=valuesOfStatementOfSense(sb,languageStylePIDs);\n\t\t\t\n\t\t\tconst lsav=Math.min(...lsa.map((v)=\u003E{\n\t\t\t\treturn styleRank.findIndex((a)=\u003Ea===v);\n\t\t\t}));\n\t\t\tconst lsbv=Math.min(...lsb.map((v)=\u003E{\n\t\t\t\treturn styleRank.findIndex((a)=\u003Ea===v);\n\t\t\t}));\n\t\t\t\n\t\t\tif (lsav!==lsbv){\n\t\t\t\treturn lsav\u003Clsbv ? 1 : -1;\n\t\t\t}\n\t\t\t\n\t\t\t//worst lexical category\n\t\t\tconst wlcav=worstLexicalCategoryRank.findIndex((v)=\u003Ev===a.Z6005K4.Z6091K1);\n\t\t\tconst wlcbv=worstLexicalCategoryRank.findIndex((v)=\u003Ev===b.Z6005K4.Z6091K1);\n\t\t\tif (wlcav!==wlcbv){\n\t\t\t\tif (wlcav===-1) return -1;\n\t\t\t\tif (wlcbv===-1) return 1;\n\t\t\t\treturn wlcav\u003Cwlcbv ? 1 : -1;\n\t\t\t}\n\t\t\t\n\t\t\t// Lemma è nomeItem\n\t\t\tif (a.Z6005K2.Z12K1[0].Z11K2.toLocaleLowerCase(a.Z6005K2.Z12K1[0].Z11K1.Z60K1)===nomeItem.toLocaleLowerCase(a.Z6005K2.Z12K1[0].Z11K1.Z60K1)){\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t\tif (b.Z6005K2.Z12K1[0].Z11K2.toLocaleLowerCase(b.Z6005K2.Z12K1[0].Z11K1.Z60K1)===nomeItem.toLocaleLowerCase(b.Z6005K2.Z12K1[0].Z11K1.Z60K1)){\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t\t\n\t\t\t//best lexical category\n\t\t\tconst blcav=bestLexicalCategoryRank[linkingPredicatea].findIndex((v)=\u003Ev===a.Z6005K4.Z6091K1);\n\t\t\tconst blcbv=bestLexicalCategoryRank[linkingPredicateb].findIndex((v)=\u003Ev===b.Z6005K4.Z6091K1);\n\t\t\tif (blcav!==blcbv){\n\t\t\t\treturn blcav\u003Cblcbv ? 1 : -1;\n\t\t\t}\n\t\t\t\n\t\t\t\n\t\t\treturn 0;\n\t\t}\n\t\t\n\t\tconst sorted=Z27332K1.sort(compare);\n\t\treturn sorted;\n\t}\n\tvar QIDs=Z30177K1.map(v=\u003Ev.Z6091K1);\n\tvar elElementi=Array(Z30177K1.length);\n\tvar elLessemi=Array(Z30177K1.length);\n\tvar elMetadatiLessemi=Array(Z30177K1.length);\n\tfor (let i=0; i\u003CZ30177K1.length; ++i){\n\t\telLessemi[i]=[];\n\t\telMetadatiLessemi[i]=[];\n\t}\n\t\n\tfor (const [k,v] of Z30177K2){\n\t\tif (tipo(v)===\"Z6001\"){\n\t\t\telElementi[QIDs.findIndex(i=\u003Ei===v.Z6001K1.Z6091K1)]=v;\n\t\t} else {\n\t\t\t// return [JSON.stringify(v)];\n\t\t\tfor (const [s,i] of relevantSenses(v,QIDs)){\n\t// return [JSON.stringify(s),JSON.stringify(i)]\n\t\t\t\telLessemi[i].push(v);\n\t\t\t\telMetadatiLessemi[i].push({senso:s});\n\t\t\t}\n\t\t}\n\t}\n\tlet ret=[];\n\tfor (let iQID=0; iQID\u003CZ30177K1.length; ++iQID){\n\t\tif (elLessemi[iQID].length===0){\n\t\t// return [\"cio\"]\n\t\t\tret.push(etichettaElemento(elElementi[iQID],Z30177K4));\n\t\t} else {\n\t\t\tconst elLess=miglioriLessemi(elLessemi[iQID],Z30177K1[iQID],etichettaElemento(elElementi[iQID],Z30177K4));\n\t\t\tret.push(etichettaLessema(elLess[0],Z30177K4));\n\t\t\t// ret.push(etichettaElemento(elElementi[iQID],Z30177K4));\n\t\t}\n\t}\n\treturn ret;\n}"
        }
    },
    "Z2K3": {
        "Z1K1": "Z12",
        "Z12K1": [
            "Z11",
            {
                "Z1K1": "Z11",
                "Z11K1": "Z1787",
                "Z11K2": "lista di nomi per titolo di tabella da mappa, js"
            }
        ]
    },
    "Z2K4": {
        "Z1K1": "Z32",
        "Z32K1": [
            "Z31"
        ]
    },
    "Z2K5": {
        "Z1K1": "Z12",
        "Z12K1": [
            "Z11"
        ]
    }
}