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

Implementation of intersection algorithm for regular grammars #34

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from

Conversation

bahbyega
Copy link

No description provided.

curr_front = list()
visited = Vector.sparse(BOOL, num_verts_inter)

for regex_start_st in regex_start_states:
Copy link
Member

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:
Copy link
Member

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:
Copy link
Member

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?

Copy link
Member

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?

@bahbyega bahbyega requested a review from gsvgit March 11, 2022 07:44
assert not intersect_bfs.accepts(["c", "a"])

assert intersect_kron.is_equivalent_to(intersect_bfs)
assert result.nvals == 2 * len(source_verts)
Copy link
Member

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
Copy link
Member

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()
Copy link
Member

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?

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

Successfully merging this pull request may close these issues.

2 participants