Z24556

{
    "Z1K1": "Z2",
    "Z2K1": {
        "Z1K1": "Z6",
        "Z6K1": "Z24556"
    },
    "Z2K2": {
        "Z1K1": "Z14",
        "Z14K1": "Z24483",
        "Z14K3": {
            "Z1K1": "Z16",
            "Z16K1": "Z600",
            "Z16K2": "function Z24483(Z24483K1, Z24483K2, Z24483K3) {\n    const requested = Z24483K2.map(f =\u003E f.Z6091K1);\n    const requestedSet = new Set(requested);\n\n    const rankedForms = Z24483K1.Z6005K7.map((form, index) =\u003E {\n        const actualSet = new Set(form.Z6004K4.map(f =\u003E f.Z6091K1));\n        const intersectionSize = requested.filter(f =\u003E actualSet.has(f)).length;\n        const noise = actualSet.size - intersectionSize;\n\n        const matchVector = requested.map(f =\u003E actualSet.has(f) ? 1 : 0);\n\n        return { form, intersectionSize, matchVector, noise, index };\n    });\n\n    rankedForms.sort((a, b) =\u003E {\n        if (b.intersectionSize !== a.intersectionSize) return b.intersectionSize - a.intersectionSize;\n        for (let i = 0; i \u003C a.matchVector.length; i++) {\n            if (a.matchVector[i] !== b.matchVector[i]) {\n                return b.matchVector[i] - a.matchVector[i];\n            }\n        }\n        if (a.noise !== b.noise) return a.noise - b.noise;\n        return a.index - b.index;\n    });\n\n    const canonicalOrder = [...requested];\n    const seen = new Set(requested);\n    const preferredLangs = Z24483K3.map(lang =\u003E lang.Z60K1);\n\n    // Add lexeme language if not already included\n    const lexemeLang = Z24483K1.Z6005K3;\n    if (!preferredLangs.includes(lexemeLang)) {\n        preferredLangs.push(lexemeLang);\n    }\n\n    // Add lemma representation languages if not already included\n    for (const rep of Z24483K1.Z6005K2.Z12K1) {\n        const lang = rep.Z11K1.Z60K1;\n        if (!preferredLangs.includes(lang)) {\n            preferredLangs.push(lang);\n        }\n    }\n\n    const orderedForms = rankedForms.map(({ form }) =\u003E {\n        for (const f of form.Z6004K4) {\n            const id = f.Z6091K1;\n            if (!seen.has(id)) {\n                seen.add(id);\n                canonicalOrder.push(id);\n            }\n        }\n\n        const reps = form.Z6004K3.Z12K1;\n        const sortedReps = [];\n        const usedReps = new Set();\n\n        for (const lang of preferredLangs) {\n            for (const rep of reps) {\n                if (rep.Z11K1.Z60K1 === lang \u0026\u0026 !usedReps.has(rep)) {\n                    sortedReps.push(rep);\n                    usedReps.add(rep);\n                }\n            }\n        }\n        for (const rep of reps) {\n            if (!usedReps.has(rep)) sortedReps.push(rep);\n        }\n\n        const featureMap = new Map(form.Z6004K4.map(f =\u003E [f.Z6091K1, f]));\n        const sortedFeatures = canonicalOrder\n            .filter(id =\u003E featureMap.has(id))\n            .map(id =\u003E featureMap.get(id));\n\n        return {\n            ...form,\n            Z6004K3: { ...form.Z6004K3, Z12K1: sortedReps },\n            Z6004K4: sortedFeatures\n        };\n    });\n\n    return orderedForms.map(form =\u003E form.Z6004K3.Z12K1[0]);\n}"
        }
    },
    "Z2K3": {
        "Z1K1": "Z12",
        "Z12K1": [
            "Z11",
            {
                "Z1K1": "Z11",
                "Z11K1": "Z1002",
                "Z11K2": "lexeme form representations (1st…) JavaScript β "
            }
        ]
    },
    "Z2K4": {
        "Z1K1": "Z32",
        "Z32K1": [
            "Z31"
        ]
    },
    "Z2K5": {
        "Z1K1": "Z12",
        "Z12K1": [
            "Z11",
            {
                "Z1K1": "Z11",
                "Z11K1": "Z1002",
                "Z11K2": "#extends Z24486, adding language-defaulting to lexeme and lemmas’\n#no suitable lexeme yet identified for testing this"
            }
        ]
    }
}