Skip to content

Commit

Permalink
Revert "Update to openfst 1.7.7"
Browse files Browse the repository at this point in the history
This reverts commit 96c0a14
  • Loading branch information
tuannguyenbb committed Feb 5, 2024
1 parent 9361859 commit ff74184
Show file tree
Hide file tree
Showing 23 changed files with 114 additions and 115 deletions.
2 changes: 1 addition & 1 deletion src/bin/phones-to-prons.cc
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ int main(int argc, char *argv[]) {
if (g_kaldi_verbose_level >= 2) {
KALDI_LOG << "phn2word FST is below:";
fst::FstPrinter<StdArc> fstprinter(phn2word, NULL, NULL, NULL, false, true, "\t");
fstprinter.Print(std::cerr, "standard error");
fstprinter.Print(&std::cerr, "standard error");
KALDI_LOG << "phone sequence is: ";
for (size_t i = 0; i < phones.size(); i++)
std::cerr << phones[i] << ' ';
Expand Down
10 changes: 6 additions & 4 deletions src/chain/chain-supervision.cc
Original file line number Diff line number Diff line change
Expand Up @@ -571,8 +571,9 @@ void Supervision::Write(std::ostream &os, bool binary) const {
// Write using StdAcceptorCompactFst, making use of the fact that it's an
// acceptor.
fst::FstWriteOptions write_options("<unknown>");
fst::StdCompactAcceptorFst cfst(fst);
cfst.Write(os, write_options);
fst::StdCompactAcceptorFst::WriteFst(
fst, fst::AcceptorCompactor<fst::StdArc>(), os,
write_options);
}
} else {
KALDI_ASSERT(e2e_fsts.size() == num_sequences);
Expand All @@ -585,8 +586,9 @@ void Supervision::Write(std::ostream &os, bool binary) const {
// Write using StdAcceptorCompactFst, making use of the fact that it's an
// acceptor.
fst::FstWriteOptions write_options("<unknown>");
fst::StdCompactAcceptorFst cfst(e2e_fsts[i]);
cfst.Write(os, write_options);
fst::StdCompactAcceptorFst::WriteFst(
e2e_fsts[i], fst::AcceptorCompactor<fst::StdArc>(), os,
write_options);
}
}
WriteToken(os, binary, "</Fsts>");
Expand Down
2 changes: 1 addition & 1 deletion src/decoder/lattice-biglm-faster-decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class LatticeBiglmFasterDecoder {
if (!GetRawLattice(&fst, use_final_probs)) return false;
// std::cout << "Raw lattice is:\n";
// fst::FstPrinter<LatticeArc> fstprinter(fst, NULL, NULL, NULL, false, true);
// fstprinter.Print(std::cout, "standard output");
// fstprinter.Print(&std::cout, "standard output");
ShortestPath(fst, ofst);
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions src/fstext/context-fst-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ static void TestContextFst(bool verbose, bool use_matcher) {
std::cout << "Sequence FST is:\n";
{ // Try to print the fst.
FstPrinter<Arc> fstprinter(*f, NULL, NULL, NULL, false, true, "\t");
fstprinter.Print(std::cout, "standard output");
fstprinter.Print(&std::cout, "standard output");
}
}

Expand Down Expand Up @@ -224,7 +224,7 @@ static void TestContextFst(bool verbose, bool use_matcher) {
std::cout << "Composed FST is:\n";
{ // Try to print the fst.
FstPrinter<Arc> fstprinter(fst_composed, NULL, NULL, NULL, false, true, "\t");
fstprinter.Print(std::cout, "standard output");
fstprinter.Print(&std::cout, "standard output");
}
}

Expand Down
12 changes: 6 additions & 6 deletions src/fstext/determinize-lattice-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ template<class Arc> void TestDeterminizeLattice() {
std::cout << "FST before lattice-determinizing is:\n";
{
FstPrinter<Arc> fstprinter(*fst, NULL, NULL, NULL, false, true, "\t");
fstprinter.Print(std::cout, "standard output");
fstprinter.Print(&std::cout, "standard output");
}
VectorFst<Arc> det_fst;
try {
Expand All @@ -106,7 +106,7 @@ template<class Arc> void TestDeterminizeLattice() {
std::cout << "FST after lattice-determinizing is:\n";
{
FstPrinter<Arc> fstprinter(det_fst, NULL, NULL, NULL, false, true, "\t");
fstprinter.Print(std::cout, "standard output");
fstprinter.Print(&std::cout, "standard output");
}
assert(det_fst.Properties(kIDeterministic, true) & kIDeterministic);
// OK, now determinize it a different way and check equivalence.
Expand All @@ -117,7 +117,7 @@ template<class Arc> void TestDeterminizeLattice() {
std::cout << "Compact FST is:\n";
{
FstPrinter<CompactArc> fstprinter(compact_fst, NULL, NULL, NULL, false, true, "\t");
fstprinter.Print(std::cout, "standard output");
fstprinter.Print(&std::cout, "standard output");
}
if (kaldi::Rand() % 2 == 1)
ConvertLattice<Weight, Int>(det_fst, &compact_det_fst, false);
Expand All @@ -128,7 +128,7 @@ template<class Arc> void TestDeterminizeLattice() {
std::cout << "Compact version of determinized FST is:\n";
{
FstPrinter<CompactArc> fstprinter(compact_det_fst, NULL, NULL, NULL, false, true, "\t");
fstprinter.Print(std::cout, "standard output");
fstprinter.Print(&std::cout, "standard output");
}

assert(RandEquivalent(compact_det_fst, compact_fst, 5/*paths*/, 0.01/*delta*/, kaldi::Rand()/*seed*/, 100/*path length, max*/));
Expand All @@ -149,14 +149,14 @@ template<class Arc> void TestDeterminizeLattice2() {
std::cout << "FST before lattice-determinizing is:\n";
{
FstPrinter<Arc> fstprinter(*fst, NULL, NULL, NULL, false, true, "\t");
fstprinter.Print(std::cout, "standard output");
fstprinter.Print(&std::cout, "standard output");
}
VectorFst<Arc> ofst;
DeterminizeLattice<TropicalWeight, int32>(*fst, &ofst);
std::cout << "FST after lattice-determinizing is:\n";
{
FstPrinter<Arc> fstprinter(ofst, NULL, NULL, NULL, false, true, "\t");
fstprinter.Print(std::cout, "standard output");
fstprinter.Print(&std::cout, "standard output");
}
delete fst;
}
Expand Down
46 changes: 23 additions & 23 deletions src/fstext/determinize-star-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ template<class Arc> void TestDeterminizeGeneral() {
std::cout << "FST before determinizing is:\n";
{
FstPrinter<Arc> fstprinter(*fst, NULL, NULL, NULL, false, true, "\t");
fstprinter.Print(std::cout, "standard output");
fstprinter.Print(&std::cout, "standard output");
}
VectorFst<Arc> ofst;
try {
DeterminizeStar<Fst<Arc> >(*fst, &ofst, kDelta, NULL, max_states);
std::cout << "FST after determinizing is:\n";
{
FstPrinter<Arc> fstprinter(ofst, NULL, NULL, NULL, false, true, "\t");
fstprinter.Print(std::cout, "standard output");
fstprinter.Print(&std::cout, "standard output");
}
assert(RandEquivalent(*fst, ofst, 5/*paths*/, 0.01/*delta*/, kaldi::Rand()/*seed*/, 100/*path length, max*/));
} catch (...) {
Expand Down Expand Up @@ -101,15 +101,15 @@ template<class Arc> void TestDeterminize() {
std::cout <<" printing before trimming\n";
{
FstPrinter<Arc> fstprinter(*fst, sptr, sptr, NULL, false, true, "\t");
fstprinter.Print(std::cout, "standard output");
fstprinter.Print(&std::cout, "standard output");
}
// Trim resulting FST.
Connect(fst);

std::cout <<" printing after trimming\n";
{
FstPrinter<Arc> fstprinter(*fst, sptr, sptr, NULL, false, true, "\t");
fstprinter.Print(std::cout, "standard output");
fstprinter.Print(&std::cout, "standard output");
}

VectorFst<Arc> *fst_copy_orig = new VectorFst<Arc>(*fst);
Expand All @@ -122,7 +122,7 @@ template<class Arc> void TestDeterminize() {
std::cout <<" printing after predeterminization\n";
{
FstPrinter<Arc> fstprinter(*fst, sptr, sptr, NULL, false, true, "\t");
fstprinter.Print(std::cout, "standard output");
fstprinter.Print(&std::cout, "standard output");
}


Expand All @@ -138,7 +138,7 @@ template<class Arc> void TestDeterminize() {
std::cout <<" printing after epsilon removal\n";
{
FstPrinter<Arc> fstprinter(*fst, sptr, sptr, NULL, false, true, "\t");
fstprinter.Print(std::cout, "standard output");
fstprinter.Print(&std::cout, "standard output");
}
VectorFst<Arc> ofst_orig;
VectorFst<Arc> ofst_star;
Expand All @@ -157,14 +157,14 @@ template<class Arc> void TestDeterminize() {
{
std::cout <<" printing after determinization [baseline]\n";
FstPrinter<Arc> fstprinter(ofst_orig, sptr, sptr, NULL, false, true, "\t");
fstprinter.Print(std::cout, "standard output");
fstprinter.Print(&std::cout, "standard output");
assert(ofst_orig.Properties(kIDeterministic, true) == kIDeterministic);
}

{
std::cout <<" printing after determinization [star]\n";
FstPrinter<Arc> fstprinter(ofst_star, sptr, sptr, NULL, false, true, "\t");
fstprinter.Print(std::cout, "standard output");
fstprinter.Print(&std::cout, "standard output");
assert(ofst_star.Properties(kIDeterministic, true) == kIDeterministic);
}

Expand All @@ -174,7 +174,7 @@ template<class Arc> void TestDeterminize() {
std::cout <<" printing after removing "<<num_removed<<" instances of extra symbols\n";
{
FstPrinter<Arc> fstprinter(ofst_star, sptr, sptr, NULL, false, true, "\t");
fstprinter.Print(std::cout, "standard output");
fstprinter.Print(&std::cout, "standard output");
}

std::cout <<" Checking equivalent to original FST.\n";
Expand Down Expand Up @@ -242,15 +242,15 @@ template<class Arc> void TestPush() {
std::cout <<" printing before trimming\n";
{
FstPrinter<Arc> fstprinter(*fst, sptr, sptr, NULL, false, true, "\t");
fstprinter.Print(std::cout, "standard output");
fstprinter.Print(&std::cout, "standard output");
}
// Trim resulting FST.
Connect(fst);

std::cout <<" printing after trimming\n";
{
FstPrinter<Arc> fstprinter(*fst, sptr, sptr, NULL, false, true, "\t");
fstprinter.Print(std::cout, "standard output");
fstprinter.Print(&std::cout, "standard output");
}

VectorFst<Arc> *fst_copy_orig = new VectorFst<Arc>(*fst);
Expand All @@ -267,7 +267,7 @@ template<class Arc> void TestPush() {
std::cout <<" printing after pushing\n";
{
FstPrinter<Arc> fstprinter(fst_pushed, sptr, sptr, NULL, false, true, "\t");
fstprinter.Print(std::cout, "standard output");
fstprinter.Print(&std::cout, "standard output");
}

assert(RandEquivalent(*fst, fst_pushed, 5/*paths*/, 0.01/*delta*/, kaldi::Rand()/*seed*/, 100/*path length-- max?*/));
Expand Down Expand Up @@ -320,15 +320,15 @@ template<class Arc> void TestMinimize() {
std::cout <<" printing before trimming\n";
{
FstPrinter<Arc> fstprinter(*fst, sptr, sptr, NULL, false, true, "\t");
fstprinter.Print(std::cout, "standard output");
fstprinter.Print(&std::cout, "standard output");
}
// Trim resulting FST.
Connect(fst);

std::cout <<" printing after trimming\n";
{
FstPrinter<Arc> fstprinter(*fst, sptr, sptr, NULL, false, true, "\t");
fstprinter.Print(std::cout, "standard output");
fstprinter.Print(&std::cout, "standard output");
}

VectorFst<Arc> *fst_copy_orig = new VectorFst<Arc>(*fst);
Expand All @@ -341,7 +341,7 @@ template<class Arc> void TestMinimize() {
std::cout <<" printing after predeterminization\n";
{
FstPrinter<Arc> fstprinter(*fst, sptr, sptr, NULL, false, true, "\t");
fstprinter.Print(std::cout, "standard output");
fstprinter.Print(&std::cout, "standard output");
}


Expand All @@ -357,7 +357,7 @@ template<class Arc> void TestMinimize() {
std::cout <<" printing after epsilon removal\n";
{
FstPrinter<Arc> fstprinter(*fst, sptr, sptr, NULL, false, true, "\t");
fstprinter.Print(std::cout, "standard output");
fstprinter.Print(&std::cout, "standard output");
}
VectorFst<Arc> ofst_orig;
VectorFst<Arc> ofst_star;
Expand All @@ -370,7 +370,7 @@ template<class Arc> void TestMinimize() {
{
std::cout <<" printing after determinization [baseline]\n";
FstPrinter<Arc> fstprinter(ofst_orig, sptr, sptr, NULL, false, true, "\t");
fstprinter.Print(std::cout, "standard output");
fstprinter.Print(&std::cout, "standard output");
}


Expand All @@ -382,7 +382,7 @@ template<class Arc> void TestMinimize() {
{
std::cout <<" printing after determinization by DeterminizeStar [in gallic]\n";
FstPrinter<GallicArc< Arc> > fstprinter(gallic_fst, sptr, sptr, NULL, false, true, "\t");
fstprinter.Print(std::cout, "standard output");
fstprinter.Print(&std::cout, "standard output");
}


Expand All @@ -392,7 +392,7 @@ template<class Arc> void TestMinimize() {
{
std::cout <<" printing after pushing weights [in gallic]\n";
FstPrinter<GallicArc< Arc> > fstprinter(gallic_fst, sptr, sptr, NULL, false, true, "\t");
fstprinter.Print(std::cout, "standard output");
fstprinter.Print(&std::cout, "standard output");
}


Expand All @@ -401,7 +401,7 @@ template<class Arc> void TestMinimize() {
{
std::cout <<" printing after minimization [in gallic]\n";
FstPrinter<GallicArc< Arc> > fstprinter(gallic_fst, sptr, sptr, NULL, false, true, "\t");
fstprinter.Print(std::cout, "standard output");
fstprinter.Print(&std::cout, "standard output");
}

printf("Converting gallic back to regular [my approach]\n");
Expand All @@ -410,15 +410,15 @@ template<class Arc> void TestMinimize() {
{
std::cout <<" printing factor-weight FST\n";
FstPrinter<GallicArc< Arc> > fstprinter(fwfst, sptr, sptr, NULL, false, true, "\t");
fstprinter.Print(std::cout, "standard output");
fstprinter.Print(&std::cout, "standard output");
}

Map(fwfst, &ofst_star, FromGallicMapper<Arc, GALLIC_LEFT>());

{
std::cout <<" printing after converting back to regular FST\n";
FstPrinter<Arc> fstprinter(ofst_star, sptr, sptr, NULL, false, true, "\t");
fstprinter.Print(std::cout, "standard output");
fstprinter.Print(&std::cout, "standard output");
}

}
Expand All @@ -431,7 +431,7 @@ template<class Arc> void TestMinimize() {
std::cout <<" printing after removing "<<num_removed<<" instances of extra symbols\n";
{
FstPrinter<Arc> fstprinter(ofst_star, sptr, sptr, NULL, false, true, "\t");
fstprinter.Print(std::cout, "standard output");
fstprinter.Print(&std::cout, "standard output");
}

std::cout <<" Checking equivalent to original FST.\n";
Expand Down
4 changes: 2 additions & 2 deletions src/fstext/factor-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ template<class Arc> static void TestFactor() {
std::cout <<" printing before trimming\n";
{
FstPrinter<Arc> fstprinter(fst, sptr, sptr, NULL, false, true, "\t");
fstprinter.Print(std::cout, "standard output");
fstprinter.Print(&std::cout, "standard output");
}
// Trim resulting FST.
Connect(&fst);

std::cout <<" printing after trimming\n";
{
FstPrinter<Arc> fstprinter(fst, sptr, sptr, NULL, false, true, "\t");
fstprinter.Print(std::cout, "standard output");
fstprinter.Print(&std::cout, "standard output");
}

if (fst.Start() == kNoStateId) return; // "Connect" made it empty.
Expand Down
12 changes: 6 additions & 6 deletions src/fstext/fstext-utils-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -375,12 +375,12 @@ void GetSymbols(const SymbolTable &symtab,
std::vector<I> *syms_out) {
KALDI_ASSERT(syms_out != NULL);
syms_out->clear();
for (SymbolTable::iterator iter = symtab.begin();
iter != symtab.end();
++iter) {
if (include_eps || iter->Label() != 0) {
syms_out->push_back(iter->Label());
KALDI_ASSERT(syms_out->back() == iter->Label()); // an integer-range thing.
for (SymbolTableIterator iter(symtab);
!iter.Done();
iter.Next()) {
if (include_eps || iter.Value() != 0) {
syms_out->push_back(iter.Value());
KALDI_ASSERT(syms_out->back() == iter.Value()); // an integer-range thing.
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/fstext/fstext-utils-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,15 @@ template<class Arc> void TestSafeDeterminizeWrapper() { // also tests SafeDete
std::cout <<" printing before trimming\n";
{
FstPrinter<Arc> fstprinter(*fst, sptr, sptr, NULL, false, true, "\t");
fstprinter.Print(std::cout, "standard output");
fstprinter.Print(&std::cout, "standard output");
}
// Trim resulting FST.
Connect(fst);

std::cout <<" printing after trimming\n";
{
FstPrinter<Arc> fstprinter(*fst, sptr, sptr, NULL, false, true, "\t");
fstprinter.Print(std::cout, "standard output");
fstprinter.Print(&std::cout, "standard output");
}

VectorFst<Arc> *fst_copy_orig = new VectorFst<Arc>(*fst);
Expand Down Expand Up @@ -362,7 +362,7 @@ void TestEqualAlign() {
template<class Arc> void Print(const Fst<Arc> &fst, std::string message) {
std::cout << message << "\n";
FstPrinter<Arc> fstprinter(fst, NULL, NULL, NULL, false, true, "\t");
fstprinter.Print(std::cout, "standard output");
fstprinter.Print(&std::cout, "standard output");
}


Expand Down
2 changes: 1 addition & 1 deletion src/fstext/kaldi-fst-io-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void WriteFstKaldi(std::ostream &os, bool binary,
bool acceptor = false, write_one = false;
FstPrinter<Arc> printer(t, t.InputSymbols(), t.OutputSymbols(),
NULL, acceptor, write_one, "\t");
printer.Print(os, "<unknown>");
printer.Print(&os, "<unknown>");
if (os.fail())
KALDI_ERR << "Stream failure detected writing FST to stream";
// Write another newline as a terminating character. The read routine will
Expand Down
Loading

0 comments on commit ff74184

Please sign in to comment.