Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/brian-gates/song-generator
Randomly generate songs for or against a candidate
https://github.com/brian-gates/song-generator
Last synced: 13 days ago
JSON representation
Randomly generate songs for or against a candidate
- Host: GitHub
- URL: https://github.com/brian-gates/song-generator
- Owner: brian-gates
- Created: 2016-10-13T03:11:58.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2016-10-13T21:40:53.000Z (about 8 years ago)
- Last Synced: 2024-11-07T14:43:35.248Z (2 months ago)
- Language: JavaScript
- Homepage:
- Size: 32.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
![Example of the interface](http://i.imgur.com/wa6T4j4.png)
1st place winner at https://github.com/neo4j-meetups/graph-hack-sfo-2016
# Run it yourself
## Prepare the Data
Install [Neo4j](https://neo4j.com/download/), then run the following queries.
Load the data:
```
LOAD CSV WITH HEADERS FROM "https://raw.githubusercontent.com/fivethirtyeight/data/master/hip-hop-candidate-lyrics/genius_hip_hop_lyrics.csv" AS row
MERGE (c:Candidate {name: row.candidate})
MERGE (a:Artist {name: row.artist})
MERGE (s:Sentiment {type: row.sentiment})
MERGE (t:Theme {type: row.theme})
MERGE (song:Song {name: row.song})
MERGE (line:Line {text: row.line})
SET line.url = row.url
MERGE (line)-[:MENTIONS]->(c)
MERGE (line)-[:HAS_THEME]->(t)
MERGE (line)-[:HAS_SENTIMENT]->(s)
MERGE (song)-[:HAS_LINE]->(line)
MERGE (a)-[r:PERFORMS]->(song)
SET r.data = row.album_release_date
```Get the last word of each line for rhyming.
```
match (n:Line)
set n.lastWord = split(n.text, ' ')[-1..];
```Create relationships between lines based on their rhyming qualities.
```
match (line1:Line), (line2:Line)
where line1 <> line2
CALL apoc.text.phoneticDelta(line1.lastWord, line2.lastWord) yield phonetic1, phonetic2, delta
MERGE (line1)-[r:phonetic]->(line2)
set r.quality = delta
```Create a few indexes for performance
```
create index on :Candidate(name);
create index on :Sentiment(type);
```## Start the server
```
node app.js
```Go to http://localhost:3001