Created
January 22, 2011 21:21
-
-
Save tingletech/791493 to your computer and use it in GitHub Desktop.
pseudo code to load SNAC data into a graph database
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
| #pseudo code | |
| # Groovy/Gremlin links | |
| # http://www.ibm.com/developerworks/java/library/j-pg04149.html#N10413 | |
| # http://www.ibm.com/developerworks/java/library/j-pg04149.html#N1049B | |
| # https://github.com/tinkerpop/gremlin/wiki/Gremlin-Methods | |
| # create graph | |
| g = new Neo4jGraph('/tmp/neo4j') | |
| create index on property "name" | |
| # first loop; define vertex for each name | |
| for ( each of the XML files) { | |
| # add vertex for record | |
| a = g.addVertex(null); | |
| # open XML file and grab name out | |
| # set property "name" to the preferred form of the name | |
| a.setProperty("name","Fred") | |
| # set property recording the name of the xml file | |
| } | |
| # second loop / now all the vertices are assigned and we can assign edges | |
| for ( each vertex in the graph ) { | |
| X = the vertex | |
| open XML file for X | |
| for ( each related person) { | |
| parse recordId: out of descriptiveNote | |
| search XTF by recordId to get preferred from of the name | |
| Y = search graph's name index to get related vertex | |
| add edge between vertices ( e.g. X-correspondedWith->Y ) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment