From c8a5e0511a535625a9b03f25352f26d686563496 Mon Sep 17 00:00:00 2001 From: Anthony Mahanna Date: Mon, 22 Jan 2024 21:42:59 -0500 Subject: [PATCH] cleanup --- README.md | 4 ++-- arango_rdf/controller.py | 10 ++++++---- arango_rdf/main.py | 28 +++++++++++++--------------- docs/quickstart.rst | 26 ++++++++++++++++---------- docs/rdf_to_arangodb_pgt.rst | 4 ++-- docs/rdf_to_arangodb_rpt.rst | 2 +- 6 files changed, 40 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 0ecca416..711b666d 100644 --- a/README.md +++ b/README.md @@ -64,8 +64,8 @@ def beatles(): **Note**: RDF-to-ArangoDB functionality has been implemented using concepts described in the paper *[Transforming RDF-star to Property Graphs: A Preliminary Analysis of Transformation Approaches](https://arxiv.org/abs/2210.05781)*. So we offer two transformation approaches: -1. RDF-Topology Preserving Transformation (RPT) -2. Property Graph Transformation (PGT) +1. [RDF-Topology Preserving Transformation (RPT)](https://arangordf.readthedocs.io/en/docs/rdf_to_arangodb_rpt.html) +2. [Property Graph Transformation (PGT)](https://arangordf.readthedocs.io/en/docs/rdf_to_arangodb_pgt.html) ```py # 1. RDF-Topology Preserving Transformation (RPT) diff --git a/arango_rdf/controller.py b/arango_rdf/controller.py index d590d716..7fcfbfe6 100644 --- a/arango_rdf/controller.py +++ b/arango_rdf/controller.py @@ -20,8 +20,9 @@ class ArangoRDFController(AbstractArangoRDFController): represents the RDF Resource in question. This local name will be used as the ArangoDB Collection name that will store **rdf_resource**. - `Read more about how the ArangoDB Collection Mapping - Process works here <../html/mapping.html>`_. + `Read more about how the PGT ArangoDB Collection Mapping + Process works here + <../html/rdf_to_arangodb_pgt.html#arangodb-collection-mapping-process>`_. """ def __init__(self) -> None: @@ -37,8 +38,9 @@ def identify_best_class( """Find the ideal RDFS Class among a selection of RDFS Classes. Essential for the ArangoDB Collection Mapping Process used in RDF-to-ArangoDB (PGT). - `Read more about how the ArangoDB Collection Mapping - Process works here <../html/mapping.html>`_. + `Read more about how the PGT ArangoDB Collection Mapping + Process works here + <../html/rdf_to_arangodb_pgt.html#arangodb-collection-mapping-process>`_. The "ideal RDFS Class" is defined as an RDFS Class whose local name best represents the RDF Resource in question. This local name will be diff --git a/arango_rdf/main.py b/arango_rdf/main.py index c5945996..85e44036 100644 --- a/arango_rdf/main.py +++ b/arango_rdf/main.py @@ -544,12 +544,10 @@ def rdf_to_arangodb_by_rpt( This method will store the RDF Resources of **rdf_graph** under the following ArangoDB Collections: - ``` - "f{name}_URIRef" # Vertex collection for `rdflib.term.URIRef`. - "f{name}_BNode" # Vertex collection for`rdflib.term.BNode`. - "f{name}_Literal" # Vertex collection for `rdflib.term.Literal`. - "f{name}_Statement" # Edge collection for all triples/quads. - ``` + 1. ``{Name}_URIRef``: Vertex collection for ``rdflib.term.URIRef`` resources. + 2. ``{Name}_BNode``: Vertex collection for ``rdflib.term.BNode`` resources. + 3. ``{Name}_Literal``: Vertex collection for ``rdflib.term.Literal`` resources. + 4. ``{Name}_Statement``: Edge collection for all triples/quads. :param name: The name of the RDF Graph :type name: str @@ -721,14 +719,16 @@ def rdf_to_arangodb_by_pgt( the Property Graph Transformation (PGT) Algorithm. PGT ensures that datatype property statements (i.e statements whose - objects are Literals) are mapped to document properties in the Property Graph. - `Learn more about PGT here <../html/pgt.html>`_. + objects are Literals) are mapped to document properties in the + Property Graph. `Learn more about PGT here + <../html/rdf_to_arangodb_pgt.html>`_. Contrary to RPT, this method will rely on the nature of the RDF Resource/Statement to determine which ArangoDB Collection it belongs to. This process is referred to as the - ArangoDB Collection Mapping Process. `Learn more about the ArangoDB - Collection Mapping Process here <../html/mapping.html>`_. + ArangoDB Collection Mapping Process. `Learn more about the PGT ArangoDB + Collection Mapping Process here + <../html/rdf_to_arangodb_pgt.html#arangodb-collection-mapping-process>`_. Contrary to RPT, regardless of whether **contextualize_graph** is set to True or not, all RDF Predicates within every RDF Statement in **rdf_graph** @@ -765,9 +765,6 @@ def rdf_to_arangodb_by_pgt( 1) Loading Meta Ontologies (i.e OWL, RDF, RDFS, etc.) into the RDF Graph 2) Providing Domain & Range Inference 3) Providing Domain & Range Introspection - - `Learn more about Graph Contextualization - here <../html/contextualization.html>`_. :type contextualize_graph: bool :param flatten_reified_triples: If set to False, will preserve the RDF structure of any Reified Triple. If set to True, will "flatten" any reified @@ -959,8 +956,9 @@ def write_adb_col_statements( The PGT Algorithm relies on the ArangoDB Collection Mapping Process to identify the ArangoDB Collection of every RDF Resource. Using this method prior to running :func:`rdf_to_arangodb_by_pgt` allows you to visualize and - modify the mapping. `Learn more about the ArangoDB Collection Mapping - Process here <../html/mapping.html>`_. + modify the mapping. `Learn more about the PGT ArangoDB + Collection Mapping Process here + <../html/rdf_to_arangodb_pgt.html#arangodb-collection-mapping-process>`_. NOTE: Running this method prior to :func:`rdf_to_arangodb_by_pgt` is unnecessary if the user is not interested in diff --git a/docs/quickstart.rst b/docs/quickstart.rst index b1d06fda..2925a961 100644 --- a/docs/quickstart.rst +++ b/docs/quickstart.rst @@ -41,28 +41,34 @@ Quickstart .. code-block:: python + # pip install arango-datasets + from arango_datasets import Datasets + + name = "OPEN_INTELLIGENCE_ANGOLA" + Datasets(db).load(name) + # 1. Graph to RDF - rdf_graph = adbrdf.arangodb_graph_to_rdf(name="BeatlesRPT", rdf_graph=Graph()) + rdf_graph = adbrdf.arangodb_graph_to_rdf(name, rdf_graph=Graph()) # 2. Collections to RDF rdf_graph_2 = adbrdf.arangodb_collections_to_rdf( - name="BeatlesRPT", + name, rdf_graph=Graph(), - v_cols={"BeatlesRPT_URIRef", "BeatlesRPT_Literal", "BeatlesRPT_BNode"}, - e_cols={"BeatlesRPT_Statement"} + v_cols={"Event", "Actor", "Source"}, + e_cols={"eventActor", "hasSource"}, ) # 3. Metagraph to RDF rdf_graph_3 = adbrdf.arangodb_to_rdf( - name="BeatlesPGT", + name=name, rdf_graph=Graph(), metagraph={ "vertexCollections": { - "Album": {"name", "date"}, - "SoloArtist": {} + "Event": {"date", "description", "fatalities"}, + "Actor": {"name"} }, "edgeCollections": { - "artist": {} - } - } + "eventActor": {} + }, + }, ) \ No newline at end of file diff --git a/docs/rdf_to_arangodb_pgt.rst b/docs/rdf_to_arangodb_pgt.rst index 47deb932..78d857dc 100644 --- a/docs/rdf_to_arangodb_pgt.rst +++ b/docs/rdf_to_arangodb_pgt.rst @@ -212,7 +212,7 @@ collection for that Resource. We are welcome to suggestions on how to improve the ArangoDB Collection Mapping Process for PGT, as we understand that it is not perfect. -Consider overriding the `ArangoRDFController <./specs.html#arango_rdf.controller.ArangoRDFController>`` Class +Consider overriding the `ArangoRDFController <./specs.html#arango_rdf.controller.ArangoRDFController>`_ Class to implement your own ArangoDB Collection Mapping Process for PGT. Supported Cases @@ -228,7 +228,7 @@ test cases range from simple RDF Graphs to complex RDF-star Graphs. ArangoRDF's PGT interface can be observed `here <./specs.html#arango_rdf.main.ArangoRDF.rdf_to_arangodb_by_pgt>`_. `View how ArangoRDF's PGT transformation approach performs on these test cases in -Colab `_. +Colab `_. .. image:: _static/cases.png :width: 500px diff --git a/docs/rdf_to_arangodb_rpt.rst b/docs/rdf_to_arangodb_rpt.rst index 1f63da18..1659b49d 100644 --- a/docs/rdf_to_arangodb_rpt.rst +++ b/docs/rdf_to_arangodb_rpt.rst @@ -145,7 +145,7 @@ test cases range from simple RDF Graphs to complex RDF-star Graphs. ArangoRDF's RPT interface can be observed `here <./specs.html#arango_rdf.main.ArangoRDF.rdf_to_arangodb_by_rpt>`_. `View how ArangoRDF's RPT transformation approach performs on these test cases in -Colab `_. +Colab `_. .. image:: _static/cases.png :width: 500px