Name: relations
Owner: inspirehep
Description: Neo4J-based module to handle INSPIRE specific relations
Created: 2015-10-27 15:00:38.0
Updated: 2015-10-27 16:09:00.0
Pushed: 2015-10-27 20:22:40.0
Homepage: null
Size: 156
Language: Python
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
A simple module built on top of neomodels, py2neo to persist citation graph information to a neo4j graph database.
install inspire_relation
port this variable - required for neomodels to connect to the database.
rt NEO4J_REST_URL=http://localhost:7474/db/data/
ython
tion_manager = RelationManager()
my_citation_network = [
{"record": 1, "references": [11, 15, 17, 18], "authors": [1, 2, 3]},
{"record": 2, "references": [15, 17, 18], "authors": [2, 3]},
{"record": 3, "references": [1, 2, 18], "authors": [3, 2]}
citation_graph_item in _dummy_citation_network:
for reference in citation_graph_item["references"]:
relation_manager.add_reference(citation_graph_item["record"], reference)
for author in citation_graph_item["authors"]:
relation_manager.add_author(citation_graph_item["record"], author)
Now, from the relation_manager you can get some information back
Give me back all the citations for record 2
tions = self.relation_manager.get_citations_for_record(2)
citation in citations:
t citation.record_id
ill return 3, referring to record 3.
Give me back the references for a record
rences = self.relation_manager.get_references_for_record(2)
reference in references:
t reference.record_id
ill return 18,17,5, referring to the 3 papers references by record 2.
Give me back the authors for a record
ors = self.relation_manager.get_authors_for_record(2)
author in authors:
t author.author_id
ill return 3 and 2, referring to the 2 author ids for record 2.
I can also easily find which papers were created by a particular author using its author ID.
thors = self.relation_manager.get_authors_for_record(2)
pers_for_author = self.relation_manager.get_papers_for_author(2)
r paper in papers_for_author:
print paper.record_id
Will return 3, 2 and 1, referring to the 3 papers authored by author 2.