Skip to content

Handle fully specified triples in mapping service #48

@cthoyt

Description

@cthoyt

In the following code block

def triples( # type:ignore
self, triple: tuple[URIRef, URIRef, URIRef]
) -> Iterable[tuple[URIRef, URIRef, URIRef]]:
"""Generate triples, overriden to dynamically generate mappings based on this graph's converter."""
subj_query, pred_query, obj_query = triple
if pred_query in self.query_predicates:
if subj_query is None and obj_query is not None:
subjects = self._expand_pair_all(obj_query)
for subj, pred in itt.product(subjects, self.query_predicates):
yield subj, pred, obj_query
elif subj_query is not None and obj_query is None:
objects = self._expand_pair_all(subj_query)
for obj, pred in itt.product(objects, self.query_predicates):
yield subj_query, pred, obj

Add the following else clause:

elif subj_query is not None and obj_query is not None:
    if obj_query in self._expand_pair_all(subj_query):
        yield subj_query, pred_query, obj_query

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions