Skip to content

Instantly share code, notes, and snippets.

@tingletech
Created January 22, 2011 21:21
Show Gist options
  • Select an option

  • Save tingletech/791493 to your computer and use it in GitHub Desktop.

Select an option

Save tingletech/791493 to your computer and use it in GitHub Desktop.
pseudo code to load SNAC data into a graph database
#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