{ "info": { "author": "Eugeniu Costetchi", "author_email": "costezki.eugen@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Utilities" ], "description": "# rdf2gremlin\n[![Build Status](https://travis-ci.org/costezki/rdf2gremlin.svg?branch=master)](https://travis-ci.org/costezki/rdf2gremlin)\n[![Coverage Status](https://coveralls.io/repos/github/costezki/rdf2gremlin/badge.svg?branch=master)](https://coveralls.io/github/costezki/rdf2gremlin?branch=master)\n[![PyPI](https://img.shields.io/pypi/v/rdf2gremlin.svg)](https://pypi.python.org/pypi/rdf2gremlin)\n[![PyPI](https://img.shields.io/pypi/pyversions/rdf2gremlin.svg)](https://pypi.python.org/pypi/rdf2gremlin)\n\nIt has never been easier to transform your RDF data into a property graph based on TinkerPop-Gremlin.\n\n\n\n# Introduction\n[Apache TinkerPop]() is a graph computing framework for both graph databases (OLTP) and graph analytic systems (OLAP). [Gremlin]() is the graph traversal language of TinkerPop.\n\nThe [Resource Description Framework (RDF)]() is a standard model for data interchange on the Web originally designed as a metadata data model. It has come to be used as a general method for conceptual description or modeling of information that is implemented in web resources, using a variety of syntax notations and data serialization formats. This linking structure forms a *directed labeled graph*, where the *edges* represent the named link between two resources, represented by the *graph nodes*. This graph view is the easiest possible mental model for RDF and is often used in easy-to-understand visual explanations. Resources are denoted by IRIs. The general convention is to use *http* URIs. \n\nRDF graphs are queries using SPARQL language. [SPARQL 1.1](https://www.w3.org/TR/sparql11-query/) is a set of specifications that provide languages and protocols to query and manipulate RDF graph content on the Web or in an RDF store. \n\nThis library, [rdf2gremlin](https://github.com/costezki/rdf2gremlin), provides an easy way to load the RDF data-sets into a property graph in order to benefit from the features of traversal language, which are not available in SPARQL pattern matching language. \n\n# Installation\n\n```shell script\n# switch to your local virtual environment \n. ./venv/activate\n\npip install rdf2gremlin\n# ... enjoy ...\n```\n\nNote: The library `tornado` shall satisfy `tornado>=4.4.1,<5.0` version restriction inherited from the python_gremlin library. \n\n\n# Prerequisites\n\nGremlin-Python is designed to connect to a \"server\" that is hosting a TinkerPop-enabled graph system. That \"server\"\ncould be [Gremlin Server](http://tinkerpop.apache.org/docs/current/reference/#gremlin-server) or a [remote Gremlin provider](http://tinkerpop.apache.org/docs/current/reference/#connecting-rgp) that exposes protocols by which Gremlin-Python can connect. This requirement is inherited by the current library as well. \n\nIn order to use this library it is necessary to have a Gremlin service available locally or on a remote location. The easiest way is to run a TinkerProp server locally. This can be done by either: \n(a) downloading and running TinkerPop \n ```shell script\nwget https://archive.apache.org/dist/tinkerpop/3.4.3/apache-tinkerpop-gremlin-server-3.4.3-bin.zip\nunzip apache-tinkerpop-gremlin-server-3.4.3-bin.zip\ncd apache-tinkerpop-gremlin-server-3.4.3/\n./bin/gremlin-server.sh start\n\n# ... to stop the server ...\n\n./bin/gremlin-server.sh stop\n```\nor (b) running it as a Docker container.\n```shell script\ndocker pull tinkerpop/gremlin-server\ndocker run --name gremlin-server -p 8182:8182 tinkerpop/gremlin-server\n\n# ... to stop the server ...\n\ndocker stop gremlin-server\n```\n\n# Getting started\n\n### Connect to a property graph service.\nA typical connection to a server running on \"localhost\" that supports the Gremlin Server protocol using websockets from the Python shell looks like this:\n\n```python\nfrom rdf2g import setup_graph\n\nDEFAULT_LOCAL_CONNECTION_STRING = \"ws://localhost:8182/gremlin\"\ng = setup_graph(DEFAULT_LOCAL_CONNECTION_STRING)\n```\nOnce `g` has been created using a connection, it is then possible to start writing Gremlin traversals to query the remote graph. \n\n### Load a graph\n\nRead an RDF graph.\n\n```python\nimport rdflib\nimport pathlib\n\nOUTPUT_FILE_LAM_PROPERTIES = pathlib.Path(\"../resource/celex_project_properties_v2.ttl\").resolve()\n\nrdf_graph = rdflib.Graph()\nrdf_graph.parse(str(OUTPUT_FILE_LAM_PROPERTIES), format=\"ttl\")\n``` \n\nLoad the RDF graph into a property graph.\n\n```python\nfrom rdf2g import load_rdf2g\nload_rdf2g(g, rdf_graph)\n```\n\nThe created property graph follows the following set of **conventions**.\n\n* URIs and Blank nodes are transformed into property graph nodes.\n* Predicates connecting an URI to another URI or a blank node are transformed into property graph edges. Edge labels correspond to qualified IRIs generated using the prefix definitions available in the RDF data-set.\n* Node labels correspond to qualified IRIs generated using the prefix definitions available in the RDF data-set. \n* RDF Litarals are transformed into values of the node properties, while the preceding predicates into keys of the node properties. In other words\n* Predicates connecting an URI to a RDF Literal are transformed into {key:value} pairs and added as node properties. \n* Nodes have a special property 'iri' that is equivalent to the absolute URI of the RDF resource.\n\n### Get a node\n\nGet a node referring to it either by label, iri or id\n```python\nskos_concept_iri = rdflib.URIRef(\"http://www.w3.org/2004/02/skos/core#Concept\")\nv1 = rdf2g.get_node(g, skos_concept_iri)\n\nskos_concept_label = \"skos:Concept\"\nv2 = rdf2g.get_node(g, skos_concept_label)\n\nhypothetical_node_id = 880\nv3 = rdf2g.get_node(g, hypothetical_node_id)\n\nprint (v1 == v2 == v3) # should be true\n```\n\nGet nodes by their supposed rdf:type. This concept is inherited, of course, from RDF world.\n```python\nskos_concept_label = \"skos:Concept\"\n\nlist_of_concept = rdf2g.get_nodes_of_type(g, skos_concept_label)\n\n# print the list of concepts in the graph\nprint (list_of_concept)\n```\n\n### Generate a traversal tree \n\nIt is possible to traverse the property graph and then generate the traversal tree from it. This is especially useful when the graph serves as structured document content say JSON or XML serialisation. \n\nTo do that first, get two levels deep traversal tree and the edges between them for all the nodes in the graph that have `iri == known_iri`. Further please see the [Gremlin reference documentation](http://tinkerpop.apache.org/docs/current/reference/#gremlin-python) at Apache TinkerPop for more information on usage.\n\n```python\nknown_iri = 'http://publications.europa.eu/resources/authority/celex/md_CODE' \ns = g.V().has('iri', known_iri).outE().inV().tree().next()\n```\n\nAltenatively use the function `rdf2g.generate_traversal_tree`\n\n```python\nnode = rdf2g.get_node(self.g, known_iri)\ns = rdf2g.generate_traversal_tree(self.g, node)\n```\n\nThen expand and simplify that tree. First, simplify the dict structure to simple Python types, removing the Gremlin objects. Second, expand by providing the properties for each visited node, while the edges are considered as special properties leading to a another node dictionary.\n\n```python\nfrom pprint import pprint\nresult = rdf2g.expand_tree(g, s)\npprint (result)\n```\n\nThe traversal tree nodes contain, in addition to original RDF content, two special properties `@id` and `@label` which correspond to the standard Gremlin `id` and `label` properties. The `@` sign is used to distinguish the original RDF from the Gremlin features. Property graph edges, are reduced to keys in the final dict and for this reason they have no additional descriptions just like in the original RDF graph.\n\n\n# Contributing\nYou are more than welcome to help expand and mature this project. \n\nWhen contributing to this repository, please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change.\n\nPlease note we have a code of conduct, please follow it in all your interactions with the project.\n\n# License\n\nThis project is Licensed under the GPL v3 License - see [LICENSE](LICENSE) file\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/costezki/rdf2gremlin", "keywords": "RDF,Gremlin,load,tinkerpop,tinkerpop3,rdf-gremlin,serialisation,", "license": "", "maintainer": "Eugeniu Costetchi", "maintainer_email": "costezki.eugen@gmail.com", "name": "rdf2gremlin", "package_url": "https://pypi.org/project/rdf2gremlin/", "platform": "any", "project_url": "https://pypi.org/project/rdf2gremlin/", "project_urls": { "Homepage": "https://github.com/costezki/rdf2gremlin" }, "release_url": "https://pypi.org/project/rdf2gremlin/0.1.38/", "requires_dist": [ "uuid", "rdflib", "pathlib", "gremlinpython", "tornado", "sphinx", "sphinxcontrib-apidoc", "myst-parser", "coverage ; extra == 'test'", "pytest ; extra == 'test'", "pytest-cov ; extra == 'test'" ], "requires_python": ">=3.6", "summary": "It has never been easier to transform your RDF data into a property graph based on TinkerPop-Gremlin.", "version": "0.1.38", "yanked": false, "yanked_reason": null }, "last_serial": 8100562, "releases": { "0.1.32": [ { "comment_text": "", "digests": { "md5": "4d38a4c0a0c1ac3b2dc65edc2f54182a", "sha256": "c8db4db0b16f781efacfe0a7d7ef674fddf309e691a098e04344811a566a0186" }, "downloads": -1, "filename": "rdf2gremlin-0.1.32.tar.gz", "has_sig": false, "md5_digest": "4d38a4c0a0c1ac3b2dc65edc2f54182a", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 8446, "upload_time": "2019-10-15T21:30:18", "upload_time_iso_8601": "2019-10-15T21:30:18.456012Z", "url": "https://files.pythonhosted.org/packages/40/48/a37a872d451e5b06aba2edad720c8bffa77a3ff15484e8f4518633c80cfe/rdf2gremlin-0.1.32.tar.gz", "yanked": false, "yanked_reason": null } ], "0.1.33": [ { "comment_text": "", "digests": { "md5": "b8c3f489541aad18035928a8a282c9de", "sha256": "9704d7e4928420967a977b93aa8a136fed2e1278fb632d9231896a57d7c41af3" }, "downloads": -1, "filename": "rdf2gremlin-0.1.33.tar.gz", "has_sig": false, "md5_digest": "b8c3f489541aad18035928a8a282c9de", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 8547, "upload_time": "2019-10-15T21:35:22", "upload_time_iso_8601": "2019-10-15T21:35:22.500252Z", "url": "https://files.pythonhosted.org/packages/1b/5d/4c09a70d384e13c33037e9e5f3e26fca10b0ef98c2159ed4f700f4012bcb/rdf2gremlin-0.1.33.tar.gz", "yanked": false, "yanked_reason": null } ], "0.1.34": [ { "comment_text": "", "digests": { "md5": "f0d5d9c5bf38d0eb68f2a37fcb1afc6d", "sha256": "c7e9f936a83fab214cf616f68aee992663138ce09b40a58eeb5d9d7328093799" }, "downloads": -1, "filename": "rdf2gremlin-0.1.34.tar.gz", "has_sig": false, "md5_digest": "f0d5d9c5bf38d0eb68f2a37fcb1afc6d", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 11658, "upload_time": "2019-10-20T00:40:10", "upload_time_iso_8601": "2019-10-20T00:40:10.834782Z", "url": "https://files.pythonhosted.org/packages/10/33/5d501fc015e32c101ed7687bd924a4566e580a7a034293117462da14844c/rdf2gremlin-0.1.34.tar.gz", "yanked": false, "yanked_reason": null } ], "0.1.35": [ { "comment_text": "", "digests": { "md5": "65894088c47d5ad4bd8690b5455068ea", "sha256": "d4ae0d7f61a02b35679cbae4a49fdf5975a20810c10bd65628f4d13ee5ea8e4d" }, "downloads": -1, "filename": "rdf2gremlin-0.1.35.tar.gz", "has_sig": false, "md5_digest": "65894088c47d5ad4bd8690b5455068ea", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 12421, "upload_time": "2019-10-26T21:54:53", "upload_time_iso_8601": "2019-10-26T21:54:53.602464Z", "url": "https://files.pythonhosted.org/packages/aa/48/2a979ec4ffd99a2691e70c478e5d8cbebca766cf4c4a03308cd81b5f8af2/rdf2gremlin-0.1.35.tar.gz", "yanked": false, "yanked_reason": null } ], "0.1.36": [ { "comment_text": "", "digests": { "md5": "273c55716c286d2070523aad7861fafa", "sha256": "d42e5d9d4dd26a06bb4896183a3ce920e79311cc07a67cbdcdc1f6bc9dc0c348" }, "downloads": -1, "filename": "rdf2gremlin-0.1.36.tar.gz", "has_sig": false, "md5_digest": "273c55716c286d2070523aad7861fafa", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 11743, "upload_time": "2019-10-28T22:24:55", "upload_time_iso_8601": "2019-10-28T22:24:55.715110Z", "url": "https://files.pythonhosted.org/packages/95/60/3554b82091aa2731a24fb81c53319044b2694da6a6ae38c37bf502d0c19f/rdf2gremlin-0.1.36.tar.gz", "yanked": false, "yanked_reason": null } ], "0.1.37": [ { "comment_text": "", "digests": { "md5": "7c306be42412011d5d1cc75dac88b60e", "sha256": "3b04e12bda1b68420fe447e64ac487176209c9cdb217c66fb1434e01077ea9ca" }, "downloads": -1, "filename": "rdf2gremlin-0.1.37.tar.gz", "has_sig": false, "md5_digest": "7c306be42412011d5d1cc75dac88b60e", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 15042, "upload_time": "2020-05-16T16:10:39", "upload_time_iso_8601": "2020-05-16T16:10:39.833920Z", "url": "https://files.pythonhosted.org/packages/ce/83/5523456c865cfae53c16960938eeb75939e20130338d823daeccce9072a7/rdf2gremlin-0.1.37.tar.gz", "yanked": false, "yanked_reason": null } ], "0.1.38": [ { "comment_text": "", "digests": { "md5": "8727c1786d398ba32dc408ac7e6b94fc", "sha256": "373735e53d4bf53962300a980886d81db6b933ea6bc39fdeb7bc0722328c6a62" }, "downloads": -1, "filename": "rdf2gremlin-0.1.38-py3-none-any.whl", "has_sig": false, "md5_digest": "8727c1786d398ba32dc408ac7e6b94fc", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 26266, "upload_time": "2020-09-03T08:28:17", "upload_time_iso_8601": "2020-09-03T08:28:17.421157Z", "url": "https://files.pythonhosted.org/packages/4f/79/6050fc4f967ded7c7bf6902f8e0942be90a6331869a616c72210f39e5e68/rdf2gremlin-0.1.38-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "735c34158b1b8044eb42b5c212934e21", "sha256": "4e70029e036d244208e9561d65186c0d5c9f74a271c77f6e3c6279b41a213eae" }, "downloads": -1, "filename": "rdf2gremlin-0.1.38.tar.gz", "has_sig": false, "md5_digest": "735c34158b1b8044eb42b5c212934e21", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 15307, "upload_time": "2020-09-03T08:28:18", "upload_time_iso_8601": "2020-09-03T08:28:18.909748Z", "url": "https://files.pythonhosted.org/packages/b6/45/72372c1021a6e4fecca7487b8fde0f3e446beb311d97072be14c2a62c9b7/rdf2gremlin-0.1.38.tar.gz", "yanked": false, "yanked_reason": null } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "8727c1786d398ba32dc408ac7e6b94fc", "sha256": "373735e53d4bf53962300a980886d81db6b933ea6bc39fdeb7bc0722328c6a62" }, "downloads": -1, "filename": "rdf2gremlin-0.1.38-py3-none-any.whl", "has_sig": false, "md5_digest": "8727c1786d398ba32dc408ac7e6b94fc", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 26266, "upload_time": "2020-09-03T08:28:17", "upload_time_iso_8601": "2020-09-03T08:28:17.421157Z", "url": "https://files.pythonhosted.org/packages/4f/79/6050fc4f967ded7c7bf6902f8e0942be90a6331869a616c72210f39e5e68/rdf2gremlin-0.1.38-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "735c34158b1b8044eb42b5c212934e21", "sha256": "4e70029e036d244208e9561d65186c0d5c9f74a271c77f6e3c6279b41a213eae" }, "downloads": -1, "filename": "rdf2gremlin-0.1.38.tar.gz", "has_sig": false, "md5_digest": "735c34158b1b8044eb42b5c212934e21", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 15307, "upload_time": "2020-09-03T08:28:18", "upload_time_iso_8601": "2020-09-03T08:28:18.909748Z", "url": "https://files.pythonhosted.org/packages/b6/45/72372c1021a6e4fecca7487b8fde0f3e446beb311d97072be14c2a62c9b7/rdf2gremlin-0.1.38.tar.gz", "yanked": false, "yanked_reason": null } ], "vulnerabilities": [] }