Wednesday, 24 February 2016

What's a graph without a laugh? Multi-lingual Graph Karaoke is HERE!

Indeed. If you follow this blog and some of my work with Neo4j a little bit, then I am hoping you know that I like to have FUN with Neo4j as well. It's actually quite amazing that you CAN in fact have fun with something as "boring" as a database - but hey, I really think you can.

I have been doing Graph Karaoke for a long time (I still blame Nigel) - and that has been a ton of fun along the way. Over the years, I gathered quite a playlist:
And now with GraphConnect Europe coming up in April, I felt like we would really need some more songs to spice up the conference. But: being in Europe - WHY would we limit ourselves to boring ENGLISH songs all the time. So I figured, there has to be a way to do Graph Karaoke in a multi-lingual way. And that's what I will be doing in the next few months - and today is the first episode in "MultiLingual Graph Karaoke".

Google Sheets to the rescue!

We'll start with a nice little Dutch song that I really like, by the world-famous (!) group "Doe Maar!". The song is "Dansmuziek", and has a lovely vibe to it, I think.

I grabbed the lyrics online, and put it in a google spreadsheet. It looks like this:
As you can see (access the sheet yourself over here), I have one column in there with the lyrics in the original, Dutch language, but I also have a couple of other columns that are automatically translated into English, German and French using the Googletranslate function of Google Sheets. I simply do:

=GOOGLETRANSLATE(C2,"nl","en")
=GOOGLETRANSLATE(C2,"nl","fr")
=GOOGLETRANSLATE(C2,"nl","de")


and these lyrics get automatically translated into the other languages. Obviously the translations will not be perfect, but hey, at least you get to do multi-lingual graph karaoke then! Yey!

Once I have this, I can download the spreadsheet as a CSV file, and then I can start working with it in Cypher. I have created an Import gist on Github - so you can basically run it yourself and import the graph at your own convenience.

Creating the Karaoke video

Once we have that, it's child's play to actually create the Karaoke video. A few very simple queries suffice:

match (w:Dutch {seq:1})
return w;




to find a sentence in a specific language. Or

match (w {seq:1})
return w;



to find a sentence in any language. And then finally also a "tabular" representation that would be easy to read:

match (w {seq:4})
where not ("SongSentence"in labels(w))
return w.seq as Sequence, labels(w) as Language, collect(w.name) as Sentence
order by Language[0]


All of that then brings me to the following - slightly stupid, I agree - slightly wonderful result:


That's it! I plan make a few more of these before GraphConnect, and publish them here as well. If you have any "song requests" in your own language, then PLEASE let me know.

Cheers

Rik

No comments:

Post a comment