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.

25 lines
721 B

  1. #include <fst/fst-decl.h>
  2. #include <fst/fstlib.h>
  3. using namespace fst;
  4. int main() {
  5. // 创建一个新的 FST
  6. StdVectorFst fst;
  7. // 添加状态
  8. fst.AddState(); // 0
  9. fst.AddState(); // 1
  10. fst.AddState(); // 2
  11. // 设置起始状态
  12. fst.SetStart(0);
  13. // 添加转移(弧)
  14. fst.AddArc(0, fst::StdArc(1, 1, 1.5, 1)); // 从状态0到状态1,输入符号为1,输出符号为1,权重为1.5,转移标识为1
  15. fst.AddArc(1, fst::StdArc(2, 2, 2.5, 2)); // 从状态1到状态2,输入符号为2,输出符号为2,权重为2.5,转移标识为2
  16. // 设置终止状态
  17. fst.SetFinal(2, 3.5); // 设置状态2为终止状态,权重为3.5
  18. return 0;
  19. }