Z27336

{
    "Z1K1": "Z2",
    "Z2K1": {
        "Z1K1": "Z6",
        "Z6K1": "Z27336"
    },
    "Z2K2": {
        "Z1K1": "Z14",
        "Z14K1": "Z27332",
        "Z14K3": {
            "Z1K1": "Z16",
            "Z16K1": "Z600",
            "Z16K2": "function Z27332( Z27332K1, Z27332K2 ) {\n\tif (Z27332K1.length===0){\n\t\tWikifunctions.Error(\"Z28170\",[\"Z27332K1\"]);\n\t}\n\tconst connItemPIDs=[\"P5137\",\"P9970\", \"P6271\"];\n\tfunction relevantSense( Z27292K1, Z27292K2 ) {\n\t\tconst linkProperties=connItemPIDs;\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 c.Z6003K3.Z6091K1===Z27292K2.Z6091K1){\n\t\t\t\t\treturn [s,c.Z6003K2.Z6092K1];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn [null,null];\n\t}\n\t\n\tfor (let i=0; i\u003CZ27332K1.length; ++i){\n\t\tif (relevantSense(Z27332K1[i],Z27332K2)[0]===null){\n\t\t\tWikifunctions.Error(\"Z28258\", [Z27332K1[i].Z6005K1.Z6095K1, //lexeme LID\n\t\t\t\t\t\t\t\"\",Z27332K2.Z6091K1, //item QID\n\t\t\t\t\t\t\t\"Z27332K1[\"+(i+1)+\"]\", \"\",\"Z27332K2\"]);\n\t\t}\n\t}\n\t\n\tfunction valuesOfStatementOfSense(s,p){\n\t\t//p is a list\n\t\tlet retList=[]\n\t\tfor (let c of s.Z6006K3){\n\t\t\tif (p.find((a)=\u003Ea===c.Z6003K2.Z6092K1) != undefined){\n\t\t\t\tretList.push(c.Z6003K3.Z6091K1);\n\t\t\t}\n\t\t}\n\t\treturn retList;\n\t}\n\t\n\tfunction rankOfStatementOfSense(s,p){\n\t\t//p is a list\n\t\tfor (let c of s.Z6006K3){\n\t\t\tif (p.find((a)=\u003Ea===c.Z6003K2.Z6092K1) != undefined){\n\t\t\t\treturn c.Z6003K4.Z6040K1.Z9K1;\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n\t\n\tconst languageStylePIDs=[\"P6191\"];\n\t\n\tconst rankRank=[\"Z6043\",\"Z6042\",\"Z6041\"];\n\tconst styleRank=[\n\t\t\"Q184439\",\t\t//profanity\n\t\t\"Q1521634\",\t\t//vulgarism\n\t\t\"Q545779\",\t\t//pejorative\n\t\t\"Q83464\",\t\t//euphemism\n\t\t\"Q58233068\",\t//humorous\n\t\t\"Q58157328\",\t//rare\n\t\t\"Q901711\",\t\t//colloqual\n\t\t\"Q181970\",\t\t//archaism\n\t\t\"Q57495609\",\t//outdated\n\t\t\"Q110983878\",\t//idiomatic\n\t\t\"Q130989\",\t\t//neologism\n\t\t];\n\t\n\tconst worstLexicalCategoryRank=[\n\t\t\"Q201322\",\t\t//prefix\n\t\t\"Q102047\",\t\t//suffix\n\t\t\"Q134830\",\t\t//prefix\n\t\t\"Q62155\",\t\t//affix\n\t\t];\n\tconst bestLexicalCategoryRank={\n\t\t//item for this sense\n\t\tP5137:[\"Q380057\",\"Q24905\",\"Q34698\",\"Q147276\",\"Q1084\"],\n\t\t//predicate for\n\t\tP9970:[\"Q24905\"],\n\t\t//denonym of\n\t\tP6271:[\"Q147276\",\"Q1084\"],\n\t\t};\n\t\n\tfunction compare(a,b){\n\t\tconst [sa,linkingPredicatea]=relevantSense(a,Z27332K2);\n\t\tconst [sb,linkingPredicateb]=relevantSense(b,Z27332K2);\n\t\t\n\t\t//ranks\n\t\tconst ra=rankOfStatementOfSense(sa,connItemPIDs);\n\t\tconst rb=rankOfStatementOfSense(sb,connItemPIDs);\n\t\t\n\t\tif (ra!==rb){\n\t\t\treturn rankRank.findIndex((a)=\u003Ea===ra) \u003C rankRank.findIndex((a)=\u003Ea===rb) ? 1 : -1;\n\t\t}\n\t\t\n\t\t//language style\n\t\tconst lsa=valuesOfStatementOfSense(sa,languageStylePIDs);\n\t\tconst lsb=valuesOfStatementOfSense(sb,languageStylePIDs);\n\t\t\n\t\tconst lsav=Math.min(...lsa.map((v)=\u003E{\n\t\t\treturn styleRank.findIndex((a)=\u003Ea===v);\n\t\t}));\n\t\tconst lsbv=Math.min(...lsb.map((v)=\u003E{\n\t\t\treturn styleRank.findIndex((a)=\u003Ea===v);\n\t\t}));\n\t\t\n\t\tif (lsav!==lsbv){\n\t\t\treturn lsav\u003Clsbv ? 1 : -1;\n\t\t}\n\t\t\n\t\t//worst lexical category\n\t\tconst wlcav=worstLexicalCategoryRank.findIndex((v)=\u003Ev===a.Z6005K4.Z6091K1);\n\t\tconst wlcbv=worstLexicalCategoryRank.findIndex((v)=\u003Ev===b.Z6005K4.Z6091K1);\n\t\tif (wlcav!==wlcbv){\n\t\t\tif (wlcav===-1) return -1;\n\t\t\tif (wlcbv===-1) return 1;\n\t\t\treturn wlcav\u003Cwlcbv ? 1 : -1;\n\t\t}\n\t\t\n\t\t//best lexical category\n\t\tconst blcav=bestLexicalCategoryRank[linkingPredicatea].findIndex((v)=\u003Ev===a.Z6005K4.Z6091K1);\n\t\tconst blcbv=bestLexicalCategoryRank[linkingPredicateb].findIndex((v)=\u003Ev===b.Z6005K4.Z6091K1);\n\t\tif (blcav!==blcbv){\n\t\t\treturn blcav\u003Cblcbv ? 1 : -1;\n\t\t}\n\t\t\n\t\treturn 0;\n\t}\n\t\n\tconst sorted=Z27332K1.sort(compare);\n\treturn sorted[0];\n}"
        }
    },
    "Z2K3": {
        "Z1K1": "Z12",
        "Z12K1": [
            "Z11",
            {
                "Z1K1": "Z11",
                "Z11K1": "Z1787",
                "Z11K2": "miglior lessema tra lista di lessemi, js"
            },
            {
                "Z1K1": "Z11",
                "Z11K1": "Z1002",
                "Z11K2": "best lexeme from list, javascript"
            }
        ]
    },
    "Z2K4": {
        "Z1K1": "Z32",
        "Z32K1": [
            "Z31"
        ]
    },
    "Z2K5": {
        "Z1K1": "Z12",
        "Z12K1": [
            "Z11"
        ]
    }
}