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

implement intersect #22

Merged
merged 1 commit into from
May 2, 2020
Merged

implement intersect #22

merged 1 commit into from
May 2, 2020

Conversation

qindazhu
Copy link
Collaborator

@qindazhu qindazhu commented May 2, 2020

No description provided.

k2/csrc/fsa_algo.cc Outdated Show resolved Hide resolved
@csukuangfj
Copy link
Collaborator

could you visualize the result and post them here?

@qindazhu
Copy link
Collaborator Author

qindazhu commented May 2, 2020

could you visualize the result and post them here?

Sure!

Input FSA a
a

Input FSA b
b

Output FSA c = a^b.
c

@csukuangfj
Copy link
Collaborator

Should the output be trimmed (connected) ?

@qindazhu
Copy link
Collaborator Author

qindazhu commented May 2, 2020

Should the output be trimmed (connected) ?

I think it's better to leave this to the caller to do that.

@csukuangfj
Copy link
Collaborator

OpenFST produces a connected fsa.

Please refer to http://www.openfst.org/twiki/bin/view/FST/IntersectDoc

@qindazhu
Copy link
Collaborator Author

qindazhu commented May 2, 2020

OpenFST produces a connected fsa.

Please refer to http://www.openfst.org/twiki/bin/view/FST/IntersectDoc

OpenFst supports kinds of filters, so callers can decide what fsa they want. However, we don't support such filters, so maybe callers want do RmEplision then Compose, etc.

Thus, I think it's better to let the caller do this instead of doing such operations (we make the decision for them) in one function call.

@csukuangfj
Copy link
Collaborator

ok.

Another point: why is there a self-loop with label epsilon in the input fsa a and the output fsa?

@qindazhu
Copy link
Collaborator Author

qindazhu commented May 2, 2020

ok.

Another point: why is there a self-loop with label epsilon in the input fsa a and the output fsa?

I guess what you are asking is why there is self-loop with label epsilon in the input fsa (as if there is one in the input, there may be such a state in the output).

Well, that's just because we support such input fsa, we only require that either a or b is epsilon-free, but not limit what labels can be on self-loop. Anyway, the caller can remove such arcs if they want.

@csukuangfj
Copy link
Collaborator

I think epsilon free means you can go to state b from a with the epslion label (i.e., no input).
But a should be different from b.

Does every node implicitly have a self-loop with label epsilon?

@qindazhu
Copy link
Collaborator Author

qindazhu commented May 2, 2020

We treat the epsilon free fsa has a self loop with epsilon at each state. Say if a has epsilon arc and b is epsilon-free. When we match Arc(src_a, dest_a, epsilon) in a with Arc(src_b, dest_b, label), we always add a arc (src_a, src_b) -> (dest_a, src_b) with label epsilon (That means we add a self-loop in src_b with epsilon)

@csukuangfj
Copy link
Collaborator

Arc(src_a, dest_a, epsilon)

I think dest_a != src_a.

From wiki: https://en.wikipedia.org/wiki/Epsilon_transition

An epsilon transition[1] (also epsilon move[1] or lambda transition) allows an automaton to change its state spontaneously, i.e. without consuming an input symbol.

An epsilon transition -->changes<--- the state.

The input fsa a has a transition

3 3 0

which confuses me.

@qindazhu
Copy link
Collaborator Author

qindazhu commented May 2, 2020

As I said before, the caller can remove there arcs (even for input fsa) if they want or they should. That's not the responsiblity of Intersect.

BTW, my point for implementing those algorithms is : we should take requirements as few as possible on the input.

@qindazhu
Copy link
Collaborator Author

qindazhu commented May 2, 2020

If there no other issues, please help to merge.

@danpovey danpovey merged commit 615d9fd into k2-fsa:master May 2, 2020
@danpovey
Copy link
Collaborator

danpovey commented May 2, 2020 via email

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.

3 participants