From 37851d22a3b5eac229bb6440133efb17567f2c96 Mon Sep 17 00:00:00 2001 From: paulklint Date: Tue, 26 Nov 2024 11:25:51 +0100 Subject: [PATCH] Changed type of vocabulary to set[str] --- src/analysis/typepal/StringSimilarity.rsc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/analysis/typepal/StringSimilarity.rsc b/src/analysis/typepal/StringSimilarity.rsc index af44681..bbacf7a 100644 --- a/src/analysis/typepal/StringSimilarity.rsc +++ b/src/analysis/typepal/StringSimilarity.rsc @@ -53,7 +53,7 @@ test bool lev9() = lev("march", "may") == 3; alias WordSim = tuple[str word, int sim]; @synopsis{Compute list of words from vocabulary, that are similar to give word w with at most maxDistance edits} -list[str] similarWords(str w, list[str] vocabulary, int maxDistance) +list[str] similarWords(str w, set[str] vocabulary, int maxDistance) = sort({ | str v <- vocabulary, d := lev(w, v), d <= maxDistance }, bool (WordSim x, WordSim y){ return x.sim < y.sim;}).word; @@ -61,6 +61,6 @@ list[str] similarWords(str w, list[str] vocabulary, int maxDistance) list[str] similarNames(Use u, TModel tm){ w = getOrgId(u); idRoles = u.idRoles; - vocabulary = [ d.orgId | d <- tm.defines, d.idRole in idRoles, isContainedIn(u.occ, d.scope) ]; + vocabulary = { d.orgId | d <- tm.defines, d.idRole in idRoles, isContainedIn(u.occ, d.scope) }; return similarWords(w, vocabulary, tm.config.cutoffForNameSimilarity); }