OpenFst的创建和读取
来源:互联网 发布:mac系统多大 编辑:程序博客网 时间:2024/05/17 21:49
http://www.openfst.org/twiki/bin/view/FST/FstQuickTour#CreatingFsts
一、可以通过两种方法创建, 一种是使用C++代码中定义的结构体和方法创建, 另一种是通过shell命令创建
1、使用C++代码:
StdVectorFst fst;fst.AddState(); //第一个状态为0fst.SetStart(0); //0是状态的id//增加状态0的转移fst.AddArc(0, StdArc(1, 1, 0.5, 1)); //第一个参数是状态idfst.AddArc(0, StdArc(2, 2, 1.5, 1));//增加状态1和它的转移fst.AddState();fst.AddArc(1, StdArc(3, 3, 2.5, 2));//增加状态2和它的转移fst.AddState();fst.SetFinal(2, 3.5); //第一个参数是状态id, 第二个参数时权重fst.Write('binary.fst'); //保存fst
2、通过shell命令方式创建
# cat > text.fst << EOF0 1 a x .50 1 b y 1.51 2 c z 2.52 3.5EOF#生成输入符号对应数字文件$ cat >isyms.txt <<EOF<eps> 0a 1b 2c 3EOF#生成输出符号对应数字文件 数字零对应的是fst中的epsilon符号$ cat >osyms.txt <<EOF<eps> 0x 1y 2z 3EOF#从三个文本文件中生成binary.fst$ fstcompile --isymbols=isyms.txt --osymbols=osyms.txt text.fst binary.fst#将symbol保留在fst中$ fstcompile --isymbols=isyms.txt --osymbols=osyms.txt --keep_isymbols --keep_osymbols text.fst binary.fst
生成的FST是这个样子
二、FST的读取同样可以使用这两种方式
1、C++代码读取
StdFst *fst = StdFst::Read("binary.fst")//Here is the standard representation of an arc:struct StdArc { typedef int Label; typedef TropicalWeight Weight; // see "FST Weights" below typedef int StateId; Label ilabel; Label olabel; Weight weight; StateId nextstate;};
2、shell方式读取FST
$ fstprint --isymbols=isyms.txt --osymbols=osyms.txt binary.fst text.fst# Draw FST using symbol table files and Graphviz dot:$ fstdraw --isymbols=isyms.txt --osymbols=osyms.txt binary.fst binary.dot$ dot -Tps binary.dot >binary.ps#查看fst信息$ fstinfo binary.fstfst type vectorarc type standardinput symbol table isyms.txtoutput symbol table osyms.txt# of states 3# of arcs 3initial state 0# of final states 1# of input/output epsilons 0# of input epsilons 0# of output epsilons 0# of accessible states 3# of coaccessible states 3# of connected states 3# of connected components 1# of strongly conn components 3input matcher youtput matcher yexpanded ymutable yacceptor yinput deterministic youtput deterministic yinput/output epsilons ninput epsilons noutput epsilons ninput label sorted youtput label sorted yweighted ycyclic ncyclic at initial state ntop sorted yaccessible ycoaccessible ystring n
未完待续。。。
阅读全文
0 0
- OpenFst的创建和读取
- 安装openfst 和 threx的经过
- openfst的python接口安装
- JSON的创建和读取
- xml文件的创建和读取
- Windows Mobile 快捷方式的读取和创建
- Windows Mobile 快捷方式的读取和创建
- 循环链表的创建和读取
- 有名管道的创建和读取
- opencv视频的读取和创建
- opencv视频的读取和创建
- Python3,列表的创建和读取
- 双向链表的创建和读取
- txt文本文档的创建和读取
- 创建和读取cookie的方法
- OpenFST notes
- openfst使用
- XML创建和读取
- Spring框架学习——HelloWorld
- Apache
- 请使用一种算法,对字符串进行升序排列
- scheduleAtFixedRate与scheduleWithFixedDelay的区别
- python学习_4
- OpenFst的创建和读取
- 51NOD 1217 Minimum Modular(数论)
- According to Bartjens UVA
- 网页直接调用android客户端的某个功能
- Android使用CursorLoader加载手机联系人
- 个人自学学习方法记录
- Python语法基础
- 运算符和输出函数
- React Native 运行报错:Cannot find entry file index.android.js in any of the roots