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.
 
 
 

28 lines
785 B

#include <fst/fst-decl.h>
#include <fst/fstlib.h>
using namespace fst;
int main() {
// 创建一个新的 FST
StdVectorFst fst;
// 添加状态
fst.AddState(); // 0
fst.AddState(); // 1
fst.AddState(); // 2
// 设置起始状态
fst.SetStart(0);
// 添加转移(弧)
fst.AddArc(0, fst::StdArc(1, 1, 1.5, 1)); // 从状态0到状态1,输入符号为1,输出符号为1,权重为1.5,转移标识为1
fst.AddArc(1, fst::StdArc(2, 2, 2.5, 2)); // 从状态1到状态2,输入符号为2,输出符号为2,权重为2.5,转移标识为2
// 设置终止状态
fst.SetFinal(2, 3.5); // 设置状态2为终止状态,权重为3.5
// 输出 FST 的文本表示
fst.Write("example.fst");
return 0;
}