-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding support for constant literal values in functions (solving #71)
- Loading branch information
Showing
6 changed files
with
136 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
@prefix ex: <http://www.semanticweb.org/tijnd/>. | ||
@prefix ontology: <http://www.semanticweb.org/tijnd/ontology/>. | ||
@prefix schema: <https://schema.org/>. | ||
@prefix idlab-fn: <http://example.com/idlab/function/>. | ||
@prefix grel: <http://users.ugent.be/~bjdmeest/function/grel.ttl#>. | ||
@prefix owl: <http://www.w3.org/2002/07/owl#>. | ||
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>. | ||
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>. | ||
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>. | ||
@prefix rr: <http://www.w3.org/ns/r2rml#>. | ||
@prefix rml: <http://semweb.mmlab.be/ns/rml#>. | ||
@prefix ql: <http://semweb.mmlab.be/ns/ql#>. | ||
@prefix d2rq: <http://www.wiwiss.fu-berlin.de/suhl/bizer/D2RQ/0.1#>. | ||
@prefix foaf: <http://xmlns.com/foaf/0.1/>. | ||
@prefix schema: <http://schema.org/>. | ||
@prefix formats: <http://www.w3.org/ns/formats/>. | ||
@prefix comp: <http://semweb.mmlab.be/ns/rml-compression#>. | ||
@prefix void: <http://rdfs.org/ns/void#>. | ||
@prefix fnml: <http://semweb.mmlab.be/ns/fnml#>. | ||
@base <http://example.com/ns#>. | ||
|
||
|
||
<function_director_0> a fnml:Execution; | ||
fnml:function grel:string_split ; | ||
fnml:input | ||
[ | ||
a fnml:Input; | ||
fnml:parameter grel:p_string_sep; | ||
fnml:valueMap [ | ||
a fnml:ValueMap; | ||
rr:constant ", "; | ||
]; | ||
], | ||
[ | ||
a fnml:Input; | ||
fnml:parameter grel:valueParameter; | ||
fnml:valueMap [ | ||
a fnml:ValueMap; | ||
rml:reference "directors"; | ||
]; | ||
]. | ||
|
||
<director_0> a rr:TriplesMap; | ||
|
||
rml:logicalSource [ | ||
a rml:LogicalSource; | ||
rml:source "imdb_video_game_rating_modified.csv"; | ||
rml:referenceFormulation ql:CSV; | ||
|
||
]; | ||
rr:subjectMap [ | ||
a rr:SubjectMap; | ||
rr:template "ex:Person/{title}"; | ||
]; | ||
rr:predicateObjectMap [ | ||
rr:predicateMap [ | ||
a rr:PredicateMap; | ||
rr:constant rdf:type; | ||
]; | ||
rr:objectMap [ | ||
a rr:ObjectMap; | ||
rr:constant schema:Person; | ||
]; | ||
]; | ||
rr:predicateObjectMap [ | ||
rr:predicateMap [ | ||
a rr:PredicateMap; | ||
rr:constant schema:name; | ||
]; | ||
rr:objectMap [ | ||
a rr:ObjectMap; | ||
fnml:execution <function_director_0>; | ||
]; | ||
]. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
prefixes: | ||
ex: "http://www.semanticweb.org/tijnd/" | ||
ontology: "http://www.semanticweb.org/tijnd/ontology/" | ||
schema: "https://schema.org/" | ||
idlab-fn: "http://example.com/idlab/function/" | ||
grel: "http://users.ugent.be/~bjdmeest/function/grel.ttl#" | ||
owl: "http://www.w3.org/2002/07/owl#" | ||
rdf: "http://www.w3.org/1999/02/22-rdf-syntax-ns#" | ||
rdfs: "http://www.w3.org/2000/01/rdf-schema#" | ||
xsd: "http://www.w3.org/2001/XMLSchema#" | ||
sources: | ||
imdb: | ||
access: imdb_video_game_rating_modified.csv | ||
referenceFormulation: csv | ||
|
||
mappings: | ||
director: | ||
sources: | ||
- imdb | ||
s: ex:Person/$(title) #Not really the correct subject, only used to simply test it | ||
po: | ||
- [a, schema:Person] | ||
- p: schema:name | ||
o: | ||
function: grel:string_split | ||
parameters: | ||
- [grel:p_string_sep, ", "] | ||
- [grel:valueParameter, $(directors)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
__author__ = "David Chaves-Fraga" | ||
__credits__ = ["David Chaves-Fraga"] | ||
|
||
__license__ = "Apache-2.0" | ||
__maintainer__ = "David Chaves-Fraga" | ||
__email__ = "[email protected]" | ||
|
||
|
||
import os | ||
from ruamel.yaml import YAML | ||
import yatter | ||
from rdflib.graph import Graph | ||
from rdflib import compare | ||
|
||
|
||
def test_yarrrmltc0050b(): | ||
expected_mapping = Graph() | ||
expected_mapping.parse(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'mapping.ttl'), format="ttl") | ||
|
||
translated_mapping = Graph() | ||
yaml = YAML(typ='safe', pure=True) | ||
mapping_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'mapping.yml') | ||
translated_mapping.parse(data=yatter.translate(yaml.load(open(mapping_path))), format="ttl") | ||
|
||
assert compare.isomorphic(expected_mapping, translated_mapping) |