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

only kFinalSymobl arcs enter final state #15

Merged
merged 1 commit into from
Apr 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions k2/csrc/properties.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ bool IsValid(const Fsa &fsa) {
// the number of arcs in one state
int32_t num_arcs = 0;
for (const auto &arc : fsa.arcs) {
// only epsilon arcs enter the final state
if (arc.dest_state == final_state && arc.label != kEpsilon) return false;
// only kFinalSymbol arcs enter the final state
if (arc.dest_state == final_state && arc.label != kFinalSymbol)
return false;
if (arc.src_state == state) {
++num_arcs;
} else {
Expand Down
2 changes: 1 addition & 1 deletion k2/csrc/properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ enum Properties {
/*
`fsa` is valid if:
1. it is empty, if not, it contains at least two states.
2. only epsilon arcs enter the final state.
2. only kFinalSymbol arcs enter the final state.
3. every state contains at least one arc except the final state.
4. `arcs_indexes` and `arcs` in this state are not consistent.
TODO(haowen): add more rules?
Expand Down
6 changes: 3 additions & 3 deletions k2/csrc/properties_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ TEST(Properties, IsNotValid) {
EXPECT_FALSE(is_valid);
}

// only epsilon arcs enter the final state
// only kFinalSymbol arcs enter the final state
{
Fsa fsa;
std::vector<Arc> arcs = {
Expand Down Expand Up @@ -113,8 +113,8 @@ TEST(Properties, IsValid) {
{
std::vector<Arc> arcs = {
{0, 1, 0},
{0, 2, 0},
{1, 2, 0},
{0, 2, kFinalSymbol},
{1, 2, kFinalSymbol},
};
std::vector<int32_t> arc_indexes = {0, 2, 3};
Fsa fsa;
Expand Down