MEntity::name
and name
Use the Levenshtein algorithm on all the indexed mentities name
.
Warning: may not scale to large indexes.
# Rank all mentities by the distance between `MEntity::name` and `name`
#
# Use the Levenshtein algorithm on all the indexed mentities `name`.
# Warning: may not scale to large indexes.
fun find_by_name_similarity(name: String, filter: nullable ModelFilter): IndexMatches do
var results = new IndexMatches
for match in name_distances.search(name) do
var dist = match.distance
var mname = match.key
if not names.has_key(mname) then continue
for mentity in names[mname] do
if mentity isa MClassDef or mentity isa MPropDef then continue
if filter != null and not filter.accept_mentity(mentity) then continue
results.add new IndexMatch(mentity, dist)
end
end
return results
end
src/model/model_index.nit:356,2--373,4