Created
April 15, 2020 21:40
-
-
Save moxious/0442df14fbfbb5cb3e281d4703b6f955 to your computer and use it in GitHub Desktop.
Emojigraph
This file contains 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
CREATE INDEX ON :Emoji(name); | |
CREATE INDEX ON :Emoji(column_a); | |
CREATE INDEX ON :Emoji(browser); | |
CREATE INDEX ON :Emoji(code); | |
CREATE INDEX ON :Category(name); | |
LOAD CSV WITH HEADERS FROM 'https://storage.googleapis.com/meetup-data/emojis/all-emojis.csv' as line | |
WITH line | |
WHERE line.code is not null | |
MERGE (e:Emoji { code: line.code }) | |
ON CREATE SET | |
e.name = line.cldr_short_name, | |
e.column_a = line.column_a, | |
e.browser = line.browser | |
MERGE (c:Category { name: line.category }) | |
MERGE (e)-[:IN]->(c) | |
RETURN count(e); | |
LOAD CSV WITH HEADERS FROM 'https://storage.googleapis.com/meetup-data/emojis/category.csv' as line | |
MERGE (c:Category { name: line.category }) | |
RETURN count(c); | |
LOAD CSV WITH HEADERS FROM 'https://storage.googleapis.com/meetup-data/emojis/similar.csv' as line | |
MERGE (a:Category { name: line.categoryA }) | |
MERGE (b:Category { name: line.categoryB }) | |
MERGE (a)-[r:SIMILAR]->(b) | |
RETURN count(r); | |
/* Create synthetic groupings */ | |
MATCH (e:Emoji) | |
WITH e, apoc.text.split(e.name, '[ \\(\\),:-]') as words | |
UNWIND words as word | |
WITH e, word | |
WHERE not word in ['', 'with', 'a', 'the', 'them', 'an'] | |
MERGE (c:Category { name: word }) | |
ON CREATE SET c.synthetic = true | |
MERGE (e)-[r:RELATED]->(c) | |
RETURN count(r); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment