Created
August 12, 2020 17:49
-
-
Save deevis/30a4779b08d6068461066a7845368b59 to your computer and use it in GitHub Desktop.
Neo4j - fun with NLP in a graph
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"the only thing we have to fear is fear itself", | |
"get busy living or get busy dying", | |
"those who dare to fail miserably can achieve greatly", | |
"it is hard to fail , but it is worse never to have tried to succeed", | |
"love is a serious mental disease", | |
"remember that the happiest people are not those getting more but those giving more", | |
"the opposite of love is not hate , it is indifference", | |
"life is trying things to see if they work", | |
"the quick brown fox jumped over the lazy dog", | |
"you will face many defeats in life but , never let yourself be defeated", | |
"if you want to live a happy life , tie it to a goal , not to people or things", | |
with [ | |
"success is how high you bounce when you hit bottom", | |
"only put off until tomorrow what you are willing to die having left undone", | |
"a friend is someone who gives you total freedom to be yourself", | |
"never let the fear of striking out keep you from playing the game" | |
] as sentences | |
unwind range(0, size(sentences) -1) as sidx | |
with split(sentences[sidx], " ") as words | |
unwind range(0, size(words) - 2) as idx | |
merge (w1:Word {name: words[idx]}) | |
merge (w2:Word {name: words[idx+1]}) | |
merge (w1)-[:NEXT]->(w2) | |
match (you:Word{name:"you"})-[*1]->(related) return you, related | |
match (incoming:Word)-[*1..3]->(you:Word {name: "you"}) return you,incoming |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment