Created
April 25, 2017 05:36
-
-
Save rwblair/88b36170002a05ff6fab282bd7e8c269 to your computer and use it in GitHub Desktop.
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
from py2neo import Graph, Node, Relationship | |
graph = Graph("http://192.168.99.100:7474/db/data/") | |
# list all concepts | |
def list_concepts(): | |
concepts = graph.cypher.execute("MATCH (c:concept) RETURN c") | |
return concepts | |
concepts = list_concepts() | |
for concept in concepts: | |
print(concept.properties) | |
# all parent concepts | |
def parent_concepts(id): | |
parents = graph.cypher.execute("MATCH (parent:concept)-[:KINDOF]->(child:concept) WHERE child.id='{}' RETURN parent".format(id)) | |
return parents | |
# get contrasts measured by concept | |
def get_contrasts(id): | |
contrasts = graph.cypher.execute("MATCH (concept:concept)-[:MEASUREDBY]->(contrast:contrast) WHERE concept.id='{}' RETURN contrast".format(id)) | |
return contrasts | |
# return [x.properties for x in contrasts] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment