openFST - beyondnlp/nlp GitHub Wiki

openFST

openFST format( AT&T ํฌ๋งท์„ ๊ธฐ๋ณธ์œผ๋กœ ํ•œ๋‹ค )

  • arc format

    • src dest ilabel olabel [weight]
  • final state : state [weight]

  • test.fst

  • Transducer File (T.txt):

0 1 a x 0.5
0 1 b y 1.5
1 2 c z 2.5
2 3.5
  • Input Symbols File (T.isyms):
a 1
b 2
c 3
  • Output Symbols File (T.osyms):
x 1
y 2
z 3
  • Compiling : T.fst ๋ฐ”์ด๋„ˆ๋ฆฌ ํ˜•ํƒœ๋กœ ์ปดํŒŒ์ผ
    • fstcompile -isymbols=T.isyms -osymbols=T.osyms T.txt T.fst
  • Printing
    • fstprint -isymbols=T.isyms -osymbols=T.osyms T.fst >T.txt
  • Drawing : dot ํŒŒ์ผ๋กœ ๋งŒ๋“ค์–ด์„œ ํ™”๋ฉด์— ์ถœ๋ ฅ์ด ๊ฐ€๋Šฅํ•˜๋‹ค.
    • fstdraw -isymbols=T.isyms -osymbols=T.osyms T.fst >T.dot
  • Writing
    • fst.Write(โ€˜โ€˜T.fstโ€™โ€™)

Example: FST Application - Shell-Level

    * fstarcsort --sort type=olabel input.fst input sorted.fst
    * fstarcsort --sort type=ilabel model.fst model sorted.fst
  • Creates the composed FST
    * $ fstcompose input sorted.fst model sorted.fst comp.fst
  • Just keeps the output label
    * $ fstproject --project output comp.fst result.fst
  • Do it all in a single command line
    * $ fstarcsort --sort type=ilabel model.fst | fstcompose input.fst - | fstproject --project output result.fst