Use text-distance to compare a string with a list of string

I want to use string-distance method to compare given string with a list of string.
Below, each disease has a list of synonym, i want to revise these code that can use string-distance to compare the given disease to a list(d_synonym) then return.

MATCH (a:Disease)
WITH a.synonym as d_synonym
WHERE apoc.text.sorensenDiceSimilarity(a.name, "trĩ") >=  0.8
RETURN a.name as name , a as result, apoc.text.sorensenDiceSimilarity(a.name, "trĩ") as score

@nguyenphucminh2804

Sorry, I did not understand what a.name should be.
Anyway, if I got it, you have nodes like this:
CREATE (a:Disease {synonym: ["trĩ", "tri", "tre", "trĩ"]} ).


In this case, if you want to check similarity for each item of synonym list,
you could use, among other things, the UNWIND, that is:

MATCH (a:Disease) 
UNWIND a.synonym as d_synonym // unwind list
WITH apoc.text.sorensenDiceSimilarity(d_synonym, "trĩ") AS score, a AS result
WHERE score >= 0.8 // check score
RETURN result, score // return entity and score
1 Like