Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
01-25-2023 07:24 PM
Hi!
My graph is like:
The purple node PATENT is what I want to calculate.
I tried to write a piece of code to calculate and query one of the patents, the jaccard score of Device.
'''
'''
As you can see in the schema, Patent got some other type nodes linked with. Besides [Device], I want to calculate with [Field]\[Imp]\[Env]\[Algorithm]\[topic00]\[topic01]... and all other types of nodes.
So I was trying to calculate all results to be j1(named jaccard1),j2,j3,j4.... and sum all the jaccard scores to be jsum?
then,
order by jsum DESC
My expression may be a little confused...
I can only calculate one jaccard scores and order by this, I don't know how to calculate all other scores at the same time and order by jsum.
Thank you!
---
running:
Neo4j Browser version: 4.4.3
Neo4j Server version: 4.4.5 (community)
01-26-2023 08:27 AM
Try this...
MATCH (n:Patent{patent_title:'一种机器人建图定位方法'})-[:has]->(c)<-[:has]-(other:Patent)
with n,other,head(labels(c)) as type, count(c) as intersection
match (n)-[:has]->(nc) where head(labels(nc)) = type
with n,other,type,intersection,collect(nc.name) as s1
match (other)-[:has]->(oc) where head(labels(oc)) = type
with n,other,type,intersection,s1,collect(oc.name) as s2
with n,other,type,intersection,s1,s2,[x IN s2 where not x IN s1] as s21
with n,other,type,intersection,s1+s21 as uni,s1,s2
return n.patent_title,other.patent_title,type,s1,s2,((1.0*intersection)/SIZE(uni)) as jaccard
order by jaccard DESC
limit 20
01-26-2023 08:29 AM
Note, I assumed each node had just one label.
01-26-2023 08:52 PM
Thank you for replying!
Yes, each node just have one label.
I don't know what "by zero" means..
01-26-2023 09:22 PM
omg, I find that I gave [Env] label wrong property key!!
01-26-2023 10:41 PM
I've changed this to be name.
and your code worked.
I may not express myself clearly.
I want to sum all types of jaccard score. and order by the sum score.
Between two patent nodes, there will be a [device]'s jaccard score, a [algorithm]' jaccard score, a [navtech] score.... then sum all of them.
finally, order by the sum value.
All the sessions of the conference are now available online