Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle fully specified triples in mapping service #48

Open
cthoyt opened this issue Mar 18, 2023 · 0 comments
Open

Handle fully specified triples in mapping service #48

cthoyt opened this issue Mar 18, 2023 · 0 comments

Comments

@cthoyt
Copy link
Member

cthoyt commented Mar 18, 2023

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant