UNPKG

@palasimi/ipa-cluster

Version:

Cluster words with similar IPA transcriptions together

25 lines 1.06 kB
"use strict"; // SPDX-License-Identifier: GPL-3.0-or-later // Copyright (c) 2023 Levi Gruspe Object.defineProperty(exports, "__esModule", { value: true }); exports.clusterByIPA = void 0; const cost_1 = require("./cost"); const cluster_1 = require("./ipa-cluster/cluster"); const metrics_1 = require("./ipa-cluster/metrics"); // Cluster words with similar IPA transcriptions together. // Uses the OPTICS clustering algorithm and the Levenshtein distance function. // `ignores` specifies edits/sound changes to not penalize. // May raise `ParseError`. function clusterByIPA(dataset, options = {}) { const cost = (0, cost_1.createCostFunction)((options === null || options === void 0 ? void 0 : options.ignores) || ""); const metric = (p, q) => { const options = { left: p.language, right: q.language, }; return (0, metrics_1.levenshtein)(p.ipa, q.ipa, cost, options); }; return (0, cluster_1.cluster)(dataset, metric, options); } exports.clusterByIPA = clusterByIPA; //# sourceMappingURL=index.js.map