Skip to content
This repository was archived by the owner on Aug 22, 2023. It is now read-only.

Latest commit

 

History

History
50 lines (42 loc) · 1.87 KB

File metadata and controls

50 lines (42 loc) · 1.87 KB

maplib API Documentation

The mapper implements the stOTTR language with extensions for mapping asset structures inspired by the Epsilon Transformation Language. Implemented with Apache Arrow in Rust using Pola.rs. We provide a Python wrapper for the library, which allows us to create mappings using DataFrames.

API

The API is simple, and contains only one class and a few methods.

from maplib import Mapping, ResolveIRI, MintingOptions, to_graph
import polars as pl

Mapping-objects are initialized using a list of stOttr documents (each a string).

doc = """
    @prefix ex:<http://example.net/ns#>.
    ex:ExampleTemplate [?MyValue] :: {
    ottr:Triple(ex:myObject, ex:hasValue, ?MyValue)
    } .
    """
mapping = Mapping([doc])

In order to extend this template, we provide a DataFrame with a particular signature. We use the extend-method of the mapping-object.

from typing import Optional, Dict
def extend(self, 
           template: str,
           df: pl.DataFrame,
           language_tags: Optional[Dict[String, String]]=None
           ) 

The template-argument specifies the template we want to expand. We are allowed to use the prefixes in the stOttr documents when referring to these templates unless there are conflicting prefix-definitions. The parameters of the templates must be provided as identically-named columns. To provide a null-argument, just make a column of nulls.

Exporting

Multiple alternatives exist to export the mapped triples. The fastest way to serialize is the write_ntriples-method.

mapping.write_ntriples(file:str)

Alternatively, we can export the mapping to an rdflib-graph.

gr = to_graph(mapping)