Skip to content

Commit

Permalink
resolving prefixes in templates (issue #68)
Browse files Browse the repository at this point in the history
  • Loading branch information
dachafra committed Dec 19, 2023
1 parent 1aa7656 commit b33da5f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.1.0
1.1.2
3 changes: 1 addition & 2 deletions src/yatter/mapping.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from .import *
prefixes = {}


def add_mapping(mapping, mappings, it):
map_template = "<" + mapping + "_" + str(it) + "> a "
if mappings[mapping]:
Expand Down Expand Up @@ -99,7 +98,7 @@ def add_inverse_prefix(rdf_mapping):


def get_non_asserted_mappings(yarrrml_data, mapping_format):
mappings = dict.fromkeys(list(yarrrml_data.get(YARRRML_MAPPINGS).keys()))
mappings = dict.fromkeys(list(yarrrml_data.get(YARRRML_MAPPINGS).keys()))
for mapping in yarrrml_data.get(YARRRML_MAPPINGS):
keys = yarrrml_data.get(YARRRML_MAPPINGS).get(mapping).keys()
for key in keys:
Expand Down
6 changes: 5 additions & 1 deletion src/yatter/termmap.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from .constants import *


## return the type of TermMap based on the input text
def get_termmap_type(text, mapping_format):
if "$(" in text and ")" in text:
Expand All @@ -19,11 +18,16 @@ def get_termmap_type(text, mapping_format):

## Generates a TermMap (subject, predicate, object) based on the property, class and the text
def generate_rml_termmap(rml_property, rml_class, text, identation, mapping_format=RML_URI):
from .mapping import prefixes
template = identation[0:-1] + rml_property + " [\n"+identation+"a " + rml_class + ";\n" + identation
term_map = get_termmap_type(text, mapping_format)
if term_map == R2RML_TEMPLATE:
text = generate_rml_template(text)
text = text.replace('"', r'\"')
if ":" in text:
text_prefix_split = text.split(":")
if text_prefix_split[0] in prefixes:
text = prefixes[text_prefix_split[0]]+text_prefix_split[1]
elif term_map == RML_REFERENCE or term_map == R2RML_COLUMN:
text = text.replace("$(", "").replace(")", "")
text = text.replace('"', r'\"')
Expand Down
2 changes: 1 addition & 1 deletion test/rml-fnml/YARRRMLTC-0050b/mapping.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
];
rr:subjectMap [
a rr:SubjectMap;
rr:template "ex:Person/{title}";
rr:template "http://www.semanticweb.org/tijnd/Person/{title}";
];
rr:predicateObjectMap [
rr:predicateMap [
Expand Down

0 comments on commit b33da5f

Please sign in to comment.