Skip to content

Commit 08145d0

Browse files
authored
Merge pull request #15 from qindazhu/haowen-fsa-property
only kFinalSymobl arcs enter final state
2 parents a960bf6 + 477e17a commit 08145d0

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

k2/csrc/properties.cc

+3-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ bool IsValid(const Fsa &fsa) {
2626
// the number of arcs in one state
2727
int32_t num_arcs = 0;
2828
for (const auto &arc : fsa.arcs) {
29-
// only epsilon arcs enter the final state
30-
if (arc.dest_state == final_state && arc.label != kEpsilon) return false;
29+
// only kFinalSymbol arcs enter the final state
30+
if (arc.dest_state == final_state && arc.label != kFinalSymbol)
31+
return false;
3132
if (arc.src_state == state) {
3233
++num_arcs;
3334
} else {

k2/csrc/properties.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ enum Properties {
2828
/*
2929
`fsa` is valid if:
3030
1. it is empty, if not, it contains at least two states.
31-
2. only epsilon arcs enter the final state.
31+
2. only kFinalSymbol arcs enter the final state.
3232
3. every state contains at least one arc except the final state.
3333
4. `arcs_indexes` and `arcs` in this state are not consistent.
3434
TODO(haowen): add more rules?

k2/csrc/properties_test.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ TEST(Properties, IsNotValid) {
2828
EXPECT_FALSE(is_valid);
2929
}
3030

31-
// only epsilon arcs enter the final state
31+
// only kFinalSymbol arcs enter the final state
3232
{
3333
Fsa fsa;
3434
std::vector<Arc> arcs = {
@@ -113,8 +113,8 @@ TEST(Properties, IsValid) {
113113
{
114114
std::vector<Arc> arcs = {
115115
{0, 1, 0},
116-
{0, 2, 0},
117-
{1, 2, 0},
116+
{0, 2, kFinalSymbol},
117+
{1, 2, kFinalSymbol},
118118
};
119119
std::vector<int32_t> arc_indexes = {0, 2, 3};
120120
Fsa fsa;

0 commit comments

Comments
 (0)