But somewhere along the way, I also started talking about my lack of a social life (so sad!!!) and the fact that I have a bit of fun with graph karaoke. I know - it's stupid. But so about half an hour before my talk, someone says "Can you do that for "Roxanne"?" ... and I am like - being a big Police fan and all - alright, Challenge Accepted.
So here's what I did:
- I grabbed the lyrics from AZLyrics
- I put it into this google sheet.
- I made the google sheet available to the public (important).
- I downloaded that sheet as a CSV file, and grabbed the URL from my downloads folder.
- and then ran this cypher query over it:
load csv with headers from "https://docs.google.com/a/neotechnology.com/spreadsheets/d/1WK-AKp-KNegaQ5-hbS79wvaNEj_SDj971iCuX9GMDSo/export?format=csv&id=1WK-AKp-KNegaQ5-hbS79wvaNEj_SDj971iCuX9GMDSo&gid=0" as csv
with csv.Sequence as seq, csv.Songsentence as row
unwind row as text
with seq, reduce(t=tolower(text), delim in [",",".","!","?",'"',":",";","'","-"] | replace(t,delim,"")) as normalized
with seq, [w in split(normalized," ") | trim(w)] as words
unwind range(0,size(words)-2) as idx
MERGE (w1:Word {name:words[idx], seq:toInt(seq)})
MERGE (w2:Word {name:words[idx+1], seq:toInt(seq)})
MERGE (w1)-[r:NEXT {seq:toInt(seq)}]->(w2)
And that's it. Graph is ready. Next I find the song in Spotify, play it a few times to rehearse, and then we get this:
So there you go. I hope you enjoyed it as much as I did. And don't forget to register for GraphConnect next week!!!
Cheers
Rik
No comments:
Post a Comment