Skip to content

Commit

Permalink
Issue #87: Fixed
Browse files Browse the repository at this point in the history
Changed initialization of primitive_event_structure at handle_primitive_event in Tree.py
  • Loading branch information
mhurvits committed Mar 15, 2022
1 parent 7c6c912 commit b30dbec
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 25 deletions.
12 changes: 4 additions & 8 deletions tree/Tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,10 @@ def __handle_primitive_event(self, tree_plan_leaf: TreePlanLeafNode, primitive_e
"""
Creates a leaf node for a primitive events.
"""
# this is a temporary hack used until the procedure is modified to extract event details from tree plan leaves

if isinstance(primitive_event_structure, NegationOperator):
primitive_event_structure = primitive_event_structure.arg
primitive_event_structure = PrimitiveEventStructure(tree_plan_leaf.event_type, tree_plan_leaf.event_name)

# this could be a composite structure that wraps a primitive event (for example Seq(Seq(a))
if isinstance(primitive_event_structure, CompositeStructure) and len(primitive_event_structure.args) == 1:
return self.__handle_primitive_event(tree_plan_leaf, primitive_event_structure.args[0], pattern_params,
Expand All @@ -116,11 +117,7 @@ def __handle_primitive_event(self, tree_plan_leaf: TreePlanLeafNode, primitive_e

real_event_index = self.__event_to_index_mapping.get(primitive_event_structure.name)

# return LeafNode(pattern_params, real_event_index, primitive_event_structure, parent)

return LeafNode(pattern_params, real_event_index, tree_plan_leaf, primitive_event_structure, parent)


return LeafNode(pattern_params, real_event_index, primitive_event_structure, parent)

def __handle_unary_structure(self, unary_tree_plan: TreePlanUnaryNode,
root_operator: PatternStructure, args: List[PatternStructure],
Expand Down Expand Up @@ -199,7 +196,6 @@ def __construct_tree(self, root_operator: PatternStructure, tree_plan: TreePlanN
else:
raise Exception("Unknown tree plan node type")


# copying the conditions of the tree_plan_node to the new node
condition_copy = deepcopy(tree_plan.condition)
# make sure the statistics collector is not copied
Expand Down
20 changes: 3 additions & 17 deletions tree/nodes/LeafNode.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,16 @@
from tree.PatternMatchStorage import TreeStorageParameters, SortedPatternMatchStorage


# class LeafNode(Node):
# """
# A leaf node is responsible for a single event type of the pattern.
# """
# def __init__(self, pattern_params: PatternParameters, leaf_index: int, leaf_event: PrimitiveEventStructure,
# parents: List[Node], pattern_ids: int or Set[int] = None):
# super().__init__(pattern_params, parents, pattern_ids)
# self.__leaf_index = leaf_index
# self.__event_name = leaf_event.name
# self.__event_type = leaf_event.type

class LeafNode(Node):
"""
A leaf node is responsible for a single event type of the pattern.
"""

def __init__(self, pattern_params: PatternParameters, leaf_index: int, tree_plan_leaf: TreePlanLeafNode, leaf_event: PrimitiveEventStructure,
def __init__(self, pattern_params: PatternParameters, leaf_index: int, leaf_event: PrimitiveEventStructure,
parents: List[Node], pattern_ids: int or Set[int] = None):
super().__init__(pattern_params, parents, pattern_ids)
self.__leaf_index = leaf_index
self.__event_name = tree_plan_leaf.event_name
self.__event_type = tree_plan_leaf.event_type
# self.__event_type = leaf_event.type

self.__event_name = leaf_event.name
self.__event_type = leaf_event.type

def create_parent_to_info_dict(self):
"""
Expand Down

0 comments on commit b30dbec

Please sign in to comment.