Skip to content

Commit

Permalink
fixed rowwise mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Hanke committed Jun 11, 2024
1 parent 3b9ca07 commit f669438
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 16 deletions.
23 changes: 15 additions & 8 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,15 +451,18 @@ def apply_mapping(
# use template to create new idivituals for every
if duplicate_for_table and rows:
# map_content=mapping_graph.serialize()
# mapping_graph.serialize('map_graph.ttl')
# mapping_graph.serialize("map_graph.ttl")
# data_graph.serialize("data_graph.ttl")
tablegroup = next(data_graph[: RDF.type : CSVW.TableGroup])
column_maps = {
column: {
column_maps = {}
for column in data_graph[: RDF.type : CSVW.Column]:
column_maps[column] = {
"po": list(mapping_graph.predicate_objects(subject=column)),
"propertyUrl": tablegroup + "/" + data_graph.value(column, CSVW.name),
"propertyUrl": next(
data_graph.objects(subject=column, predicate=CSVW.propertyUrl),
column,
),
}
for column in data_graph[: RDF.type : CSVW.Column]
}
non_column_subjects = [
subject
for subject in mapping_graph.subjects(unique=True)
Expand All @@ -472,14 +475,15 @@ def apply_mapping(
for_row_to_set = list()

# adding tripples for columns
print("column_map:{}".format(column_maps))
for column, data in column_maps.items():
print(column, data)
property = data["propertyUrl"]
for predicate, object in data["po"]:
for_row_to_set.append(
(property, predicate, strip_namespace(str(object)))
)
print(for_row_to_set)
print("to set for row: {}".format(for_row_to_set))

# adding tripples for notes
for_copy_to_set = list()
Expand Down Expand Up @@ -511,7 +515,7 @@ def apply_mapping(
)
joined_graph += mapping_graph

# joined_graph.serialize('joined.ttl')
# joined_graph.serialize("joined.ttl")

out = joined_graph.serialize(format="turtle")
out = out.replace("file:///src", data_url)
Expand Down Expand Up @@ -907,6 +911,9 @@ def check_mapping(mapping_url, data_url, authorization=None):
lookup = len(list(data_graph.subjects(item[0], item[1])))
if lookup:
found += 1
else:
print("lookup for rule {} unsuccessful".format(item))

logging.info(
"number of rules to test: {} rules with match: {}".format(len(lookups), found)
)
Expand Down
22 changes: 14 additions & 8 deletions settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,20 @@


class Setting(BaseSettings):
name: str = str(os.environ.get("APP_NAME","RDFConverter"))
contact_name: str = str(os.environ.get("ADMIN_NAME","Thomas Hanke"))
admin_email: str = str(os.environ.get("ADMIN_MAIL","[email protected]"))
name: str = str(os.environ.get("APP_NAME", "RDFConverter"))
contact_name: str = str(os.environ.get("ADMIN_NAME", "Thomas Hanke"))
admin_email: str = str(
os.environ.get("ADMIN_MAIL", "[email protected]")
)
items_per_user: int = 50
version: str = str(os.environ.get("APP_VERSION","v1.1.3"))
config_name: str = str(os.environ.get("APP_MODE","development"))
openapi_url: str ="/api/openapi.json"
version: str = str(os.environ.get("APP_VERSION", "v1.1.5"))
config_name: str = str(os.environ.get("APP_MODE", "development"))
openapi_url: str = "/api/openapi.json"
docs_url: str = "/api/docs"
source: str = str(os.environ.get("APP_SOURCE","https://github.com/Mat-O-Lab/RDFConverter"))
desc: str = "A service for joining and converting meta data documents based on YARRRML mapping files to RDF, optionally a validiation can be conducted using SHACL Shapes."
source: str = str(
os.environ.get("APP_SOURCE", "https://github.com/Mat-O-Lab/RDFConverter")
)
desc: str = (
"A service for joining and converting meta data documents based on YARRRML mapping files to RDF, optionally a validiation can be conducted using SHACL Shapes."
)
org_site: str = "https://mat-o-lab.github.io/OrgSite"

0 comments on commit f669438

Please sign in to comment.