Class RML2MappingAlgebra
java.lang.Object
se.liu.ida.hefquin.rml.RML2MappingAlgebra
This class can be used to translated RML mappings into the mapping algebra.
The translation is implemented using the algorithms introduced in the following research paper.
Sitt Min Oo and Olaf Hartig: "An Algebraic Foundation for Knowledge Graph Construction." In Proceedings of the 22nd Extended Semantic Web Conference (ESWC), 2025.
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic JsonPathQuerycheckSourceAndGetRootQuery(org.apache.jena.rdf.model.Resource tm) Checks that the logical source of the given triples map has rml:JSONPath as its reference formulation and obtains the root iterator query of the logical source.static MappingOperatorconvert(org.apache.jena.rdf.model.Resource tm, org.apache.jena.rdf.model.Model rmlDescription, org.apache.jena.graph.Node baseIRI) This implements lines 4-26 of Algorithm 1 of the paper.static ExtendExpressioncreateExtendExpression(org.apache.jena.rdf.model.Resource u, org.apache.jena.graph.Node baseIRI, Map<String, String> reverseP) This function implements Algorithm 3 of the paper.static Map<String, JsonPathQuery> Given a version of map P in which the queries are represented just as strings, this function creates a version of P in which the queries are represented asJsonPathQueryobjects.createPwithStrings(Set<String> queries) This function implements lines 11-13 of Algorithm 2 in a generic way; that is, the resulting map P contains the query string rather than concrete query objects.createReverseP(Map<String, String> PwithStrings) static SourceReferencecreateSourceReference(org.apache.jena.rdf.model.Resource tm) extractQueries(org.apache.jena.rdf.model.Resource sm, org.apache.jena.rdf.model.Resource pm, org.apache.jena.rdf.model.Resource om, org.apache.jena.rdf.model.Resource jccm, org.apache.jena.rdf.model.Resource jcpm) This function implements lines 1-10 of Algorithm 2 of the paper.static voidextractQueriesFromTemplate(String t, Set<String> queries) static voidextractQueriesOfReferenceValuedExprMap(org.apache.jena.rdf.model.Resource termMap, Set<String> queries) static voidextractQueriesOfTemplateValuedExprMap(org.apache.jena.rdf.model.Resource termMap, Set<String> queries) static List<ExtendExpression>
-
Constructor Details
-
RML2MappingAlgebra
public RML2MappingAlgebra()
-
-
Method Details
-
convert
public static MappingOperator convert(org.apache.jena.rdf.model.Resource tm, org.apache.jena.rdf.model.Model rmlDescription, org.apache.jena.graph.Node baseIRI) throws RMLParserException This implements lines 4-26 of Algorithm 1 of the paper.- Parameters:
tm-rmlDescription-baseIRI-- Returns:
- Throws:
RMLParserException
-
checkSourceAndGetRootQuery
public static JsonPathQuery checkSourceAndGetRootQuery(org.apache.jena.rdf.model.Resource tm) throws RMLParserException Checks that the logical source of the given triples map has rml:JSONPath as its reference formulation and obtains the root iterator query of the logical source.- Parameters:
tm- - assumed to represent an RML triples map- Returns:
- JSONPath query created from the rml:iterator of the logical source
- Throws:
RMLParserException
-
createSourceReference
public static SourceReference createSourceReference(org.apache.jena.rdf.model.Resource tm) throws RMLParserException - Throws:
RMLParserException
-
extractQueries
public static Set<String> extractQueries(org.apache.jena.rdf.model.Resource sm, org.apache.jena.rdf.model.Resource pm, org.apache.jena.rdf.model.Resource om, org.apache.jena.rdf.model.Resource jccm, org.apache.jena.rdf.model.Resource jcpm) This function implements lines 1-10 of Algorithm 2 of the paper.- Parameters:
sm- - the subject map of a triples mappm- - the predicate map of the same triples mapom- - the object map of the same triples mapjccm- - the child map of om, may benulljcpm- - the parent map of om, may benull- Returns:
-
extractQueriesOfReferenceValuedExprMap
-
extractQueriesOfTemplateValuedExprMap
-
extractQueriesFromTemplate
-
createPwithStrings
-
createP
public static Map<String,JsonPathQuery> createP(Map<String, String> PwithStrings, org.apache.jena.rdf.model.Resource tm) throws RMLParserExceptionGiven a version of map P in which the queries are represented just as strings, this function creates a version of P in which the queries are represented asJsonPathQueryobjects.- Parameters:
PwithStrings-tm- - the triples maps for which the given queries have been extracted; this is used only when an exception needs to be thrown- Returns:
- Throws:
RMLParserException
-
createReverseP
-
createExtendExpression
public static ExtendExpression createExtendExpression(org.apache.jena.rdf.model.Resource u, org.apache.jena.graph.Node baseIRI, Map<String, String> reverseP) throws RMLParserExceptionThis function implements Algorithm 3 of the paper.- Parameters:
u-baseIRI-reverseP- - maps the extracted query strings to the attributes to which these queries are assigned by P- Returns:
- Throws:
RMLParserException
-
split
public static List<ExtendExpression> split(String t, Map<String, String> reverseP) throws RMLParserException- Throws:
RMLParserException
-