Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
02-08-2022 07:42 AM
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
Solved! Go to Solution.
02-09-2022 09:01 AM
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
02-09-2022 09:01 AM
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
All the sessions of the conference are now available online