You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
2.4 KiB

  1. // fstext/remove-eps-local.h
  2. // Copyright 2009-2011 Microsoft Corporation
  3. // 2014 Johns Hopkins University (author: Daniel Povey)
  4. // See ../../COPYING for clarification regarding multiple authors
  5. //
  6. // Licensed under the Apache License, Version 2.0 (the "License");
  7. // you may not use this file except in compliance with the License.
  8. // You may obtain a copy of the License at
  9. //
  10. // http://www.apache.org/licenses/LICENSE-2.0
  11. //
  12. // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  13. // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  14. // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  15. // MERCHANTABLITY OR NON-INFRINGEMENT.
  16. // See the Apache 2 License for the specific language governing permissions and
  17. // limitations under the License.
  18. #ifndef KALDI_FSTEXT_REMOVE_EPS_LOCAL_H_
  19. #define KALDI_FSTEXT_REMOVE_EPS_LOCAL_H_
  20. #include <fst/fst-decl.h>
  21. #include <fst/fstlib.h>
  22. namespace fst {
  23. /// RemoveEpsLocal remove some (but not necessarily all) epsilons in an FST,
  24. /// using an algorithm that is guaranteed to never increase the number of arcs
  25. /// in the FST (and will also never increase the number of states). The
  26. /// algorithm is not optimal but is reasonably clever. It does not just remove
  27. /// epsilon arcs;it also combines pairs of input-epsilon and output-epsilon arcs
  28. /// into one.
  29. /// The algorithm preserves equivalence and stochasticity in the given semiring.
  30. /// If you want to preserve stochasticity in a different semiring (e.g. log),
  31. /// then use RemoveEpsLocalSpecial, which only works for StdArc but which
  32. /// preserves stochasticity, where possible (*) in the LogArc sense. The reason
  33. /// that we can't just cast to a different semiring is that in that case we
  34. /// would no longer be able to guarantee equivalence in the original semiring
  35. /// (this arises from what happens when we combine identical arcs).
  36. /// (*) by "where possible".. there are situations where we wouldn't be able to
  37. /// preserve stochasticity in the LogArc sense while maintaining equivalence in
  38. /// the StdArc sense, so in these situations we maintain equivalence.
  39. template <class Arc>
  40. void RemoveEpsLocal(MutableFst<Arc>* fst);
  41. /// As RemoveEpsLocal but takes care to preserve stochasticity
  42. /// when cast to LogArc.
  43. inline void RemoveEpsLocalSpecial(MutableFst<StdArc>* fst);
  44. } // namespace fst
  45. #include "fstext/remove-eps-local-inl.h"
  46. #endif // KALDI_FSTEXT_REMOVE_EPS_LOCAL_H_