Skip to content

Instantly share code, notes, and snippets.

@tbpalsulich
tbpalsulich / ascii.syms
Created May 12, 2015 19:40
Symbols file for common ascii characters to use with OpenFST
ε 0
<del> 1
<ins> 2
<sub> 3
_ 32
! 33
" 34
# 35
$ 36
% 37
@tbpalsulich
tbpalsulich / regex.fst.txt
Created May 12, 2015 19:42
Simple OpenFST formatted automaton for "a*b+c?"
0 1 &#949;
0 2 &#949;
2 2 a
2 1 &#949;
1 3 b
3 3 b
3 4 &#949;
3 4 c
4
@tbpalsulich
tbpalsulich / regex.w.fst.txt
Created May 12, 2015 19:50
Simple weighted OpenFST automaton
0 1 &#949; .5
0 2 &#949; .5
2 2 a 1
2 1 &#949; .7
1 3 b .4
3 3 b .6
3 4 &#949; .1
3 4 c .1
4
@tbpalsulich
tbpalsulich / ab.fst.txt
Created May 13, 2015 22:07
Simple replacement OpenFST transducer
0 0 a b
0 0 b b
0 0 c c
0
@tbpalsulich
tbpalsulich / uppercase.fst.txt
Created May 14, 2015 18:32
Uppercasing OpenFST transducer
0 0 a A
0 0 A A
0 0 b B
0 0 B B
0 0 c C
0 0 C C
0
@tbpalsulich
tbpalsulich / bc.fst.txt
Created May 14, 2015 18:43
OpenFST Transducer to replace 'b's with 'z's
0 0 b z
0 0 c c
0
@tbpalsulich
tbpalsulich / draw
Created May 15, 2015 14:06
Function to draw OpenFST transducers
function draw {fstdraw --isymbols=ascii.syms --osymbols=ascii.syms $1.fst | dot -Tpng -Eheadport=e -Etailport=w > $1.png}
@tbpalsulich
tbpalsulich / make_T.py
Created May 15, 2015 14:07
Python script to create an edit transistor
# &#949; = lowercase epsilon
alphabet = "abc"
weight = {
"delete": 1.0,
"insert": 1.0,
"sub": 1.0
}
# No edit
for l in alphabet:
@tbpalsulich
tbpalsulich / abc.fst.txt
Created May 15, 2015 14:23
Sample input OpenFST transducer
0 1 a a
1 2 b b
2 2 c c
2