Skip to content

Commit

Permalink
Include supertypes as :containsType members.
Browse files Browse the repository at this point in the history
Then we can check directly; should yield speedup.
  • Loading branch information
nsbgn committed Jul 26, 2023
1 parent 52a85f1 commit 5344742
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions transforge/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def __init__(self, language: Language,
with_inputs: bool | None = None,
with_workflow_origin: bool | None = None,
with_membership: bool | None = None,
with_supertype_membership: bool | None = None,
with_type_parameters: bool | None = None,
with_labels: bool | None = None,
with_classes: bool | None = None,
Expand Down Expand Up @@ -71,6 +72,7 @@ def default(switch: bool | None, inherit: bool = not minimal) -> bool:
self.with_output = default(with_output)
self.with_inputs = default(with_inputs)
self.with_membership = default(with_membership)
self.with_supertype_membership = default(with_supertype_membership)
self.with_type_parameters = default(with_type_parameters)
self.with_classes = default(with_classes)
self.with_transitive_closure = default(with_transitive_closure)
Expand Down Expand Up @@ -240,6 +242,12 @@ def add_expr(self, expr: Expr, root: Node,

if self.with_membership:
self.add((root, TF.containsType, type_node))
if (self.with_supertype_membership and
isinstance(expr.type, TypeOperation)):
for stype in self.language.supertypes(expr.type,
transitive=True):
stype_node = self.add_type(stype)
self.add((root, TF.containsType, stype_node))

if self.with_labels:
self.add((current, RDFS.label,
Expand Down

0 comments on commit 5344742

Please sign in to comment.