-
Notifications
You must be signed in to change notification settings - Fork 12
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
Implementation of intersection algorithm for regular grammars #34
base: dev
Are you sure you want to change the base?
Conversation
curr_front = list() | ||
visited = Vector.sparse(BOOL, num_verts_inter) | ||
|
||
for regex_start_st in regex_start_states: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we create a multiple-source version instead of multiple running of single-source version?
|
||
for symbol in regex: | ||
if symbol in graph: | ||
with semiring.LOR_LAND_BOOL: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess, ANY_PAIR
should be used here.
|
||
visited[prev_vert_index] = True | ||
|
||
if not found.iseq(vect) and len(list(found.I)) == 2: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks too complicated. Can it be expressed in terms of GraphBLAS vector operations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if we have multiple ways to do the next step? Why the result is limited by 2?
assert not intersect_bfs.accepts(["c", "a"]) | ||
|
||
assert intersect_kron.is_equivalent_to(intersect_bfs) | ||
assert result.nvals == 2 * len(source_verts) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we check not only size of result, but also its content?
|
||
return mask_matrix | ||
|
||
def intersect_bfs(self, src_verts) -> EpsilonNFA: | ||
""" | ||
Intersection implementation with synchronous breadth first traversal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this function solves reachability problem, not automata intersection. Isn't it?
# TODO: then here I should assign matrix elements to True | ||
with Accum(binaryop.MAX_BOOL): | ||
# extract left (grammar) part of the masks matrix and rearrange rows | ||
i_x, i_y, _ = found.extract_matrix(col_index=slice(0, num_vert_regex - 1)).to_lists() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can extract_matrix
be replaced with Python array slicing?
No description provided.