samedi 29 novembre 2014

Programmatically creating relationships between words in Neo4j using Cypher


Vote count:

0




I have a neo4j database populated with ~35K english language words. I want to create relationships between words that differ by a single letter at a given position in the word. i.e. (a)--(i) or (food)--(fool) or (cat)--(hat)


For single letter words, the cypher query is pretty simple: START n=node(), m=node() where n.name =~ '.' and m.name =~ '.' and NOT (n.name = m.name) create (n)-[:single_letter_change]->(m)


Building relationships for multiletter words is not so simple unfortunately. I know one can create a collection as in: WITH ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']· 9 AS letters and I know one can iterate over a range with: FOREACH (first IN range(0,25)


But anything I put together seems to be ugly, messy, and syntactically invalid. I am confident there is an elegant way to accomplish this in Cypher using the collection functions but I have spent a couple days trying to figure it out and it is time to ask for help.


Ideas for how to accomplish this? I will be glad to post some of the (invalid) cypher queries I have tried, but I am afraid they might just confuse the issue.



asked 44 secs ago







Programmatically creating relationships between words in Neo4j using Cypher

Aucun commentaire:

Enregistrer un commentaire