Skip to content

Commit

Permalink
solving problems with in_memory
Browse files Browse the repository at this point in the history
  • Loading branch information
dachafra committed Jan 8, 2025
1 parent 8432b46 commit 9b2a0f4
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 15 deletions.
7 changes: 4 additions & 3 deletions src/yatter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ def translate(yarrrml_data, mapping_format=RML_URI):
rml_mapping.extend(generate_database_connections(yarrrml_data, external_sources))
rml_mapping.extend(add_logical_targets(yarrrml_data, external_targets))
rml_mapping.extend(add_functions(yarrrml_data))

external_references = []
try:
mappings, mapping_format = get_non_asserted_mappings(yarrrml_data, mapping_format)
for mapping in yarrrml_data.get(YARRRML_MAPPINGS):
if mapping_format == R2RML_URI:
source_list = add_table(yarrrml_data, mapping)
else:
source_list = add_source(yarrrml_data, mapping, external_sources)
source_list, external_references = add_source(yarrrml_data, mapping, external_sources)
subject_list = add_subject(yarrrml_data, mapping, mapping_format)
pred = add_predicate_object_maps(yarrrml_data, mapping, mapping_format)
it = 0
Expand All @@ -40,7 +40,8 @@ def translate(yarrrml_data, mapping_format=RML_URI):
rml_mapping[len(rml_mapping) - 1] = rml_mapping[len(rml_mapping) - 1][:-2]
rml_mapping.append(".\n\n\n")
it = it + 1
external_refs = list(dict.fromkeys(external_refs))

external_refs = list(dict.fromkeys(external_references))
for ref in external_refs:
rml_mapping.append(ref)

Expand Down
35 changes: 26 additions & 9 deletions src/yatter/normalization.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,34 @@ def expand_source_item(source):
if isinstance(source, list):
if len(source) == 2 and isinstance(source[0], str) and '~' in source[0]:
access, reference = source[0].split('~')
return {
YARRRML_ACCESS: access,
YARRRML_REFERENCE_FORMULATION: reference,
YARRRML_ITERATOR: source[1]
}
if '-' in reference:
reference = reference.split('-')
return {
YARRRML_ACCESS: access,
YARRRML_REFERENCE_FORMULATION: reference[1],
YARRRML_STRUCTURE_DEFINER: reference[0],
YARRRML_ITERATOR: source[1]
}
else:
return {
YARRRML_ACCESS: access,
YARRRML_REFERENCE_FORMULATION: reference,
YARRRML_ITERATOR: source[1]
}
elif len(source) == 1 and isinstance(source[0], str) and '~' in source[0]:
access, reference = source[0].split('~')
return {
YARRRML_ACCESS: access,
YARRRML_REFERENCE_FORMULATION: reference
}
if '-' in reference:
reference = reference.split('-')
return {
YARRRML_ACCESS: access,
YARRRML_REFERENCE_FORMULATION: reference[1] ,
YARRRML_STRUCTURE_DEFINER: reference[0],
}
else:
return {
YARRRML_ACCESS: access,
YARRRML_REFERENCE_FORMULATION: reference,
}
elif isinstance(source, dict):
for key, val in source.items():
if isinstance(val, list) and len(val) == 2 and '~' in val[0]:
Expand Down
4 changes: 2 additions & 2 deletions src/yatter/predicateobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def ref_mapping(data, mapping, om, yarrrml_key, ref_type_property, mapping_forma
else:
if mapping_format == STAR_URI:
object = STAR_OBJECT
source_list = add_source(data, mapping_join)
source_list, external_references = add_source(data, mapping_join)

number_joins_rml = len(subject_list) * len(source_list)
for i in range(number_joins_rml):
Expand Down Expand Up @@ -259,7 +259,7 @@ def ref_cc_mapping(data, mapping, om, yarrrml_key, ref_type_property, mapping_fo
else:
if mapping_format == STAR_URI:
object = STAR_OBJECT
source_list = add_source(data, mapping_join)
source_list, external_references = add_source(data, mapping_join)

number_joins_rml = len(subject_list) * len(source_list)
for i in range(number_joins_rml):
Expand Down
1 change: 1 addition & 0 deletions src/yatter/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def add_source(data, mapping, external_sources={}):
";\n\t\t" + RML_SOURCE + " "
final_list = []
sources = data.get(YARRRML_MAPPINGS).get(mapping).get(YARRRML_SOURCES)
external_references_list = []
for source in sources:
db_identifier = mapping
for external_Source in external_sources:
Expand Down
2 changes: 1 addition & 1 deletion test/r2rml/INVERSETC-0005/mapping.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@ mappings:
s: http://example.com/Patient/$(ID)
po:
- [rdf:type, foaf:Person]
- [http://example.com/$(last_name), $(LastName), xsd:string]
- [ex:$(last_name), $(LastName), xsd:string]
- [ex:height, http://example.com/$(Height)]

0 comments on commit 9b2a0f4

Please sign in to comment.