Skip to content

Instantly share code, notes, and snippets.

@josephcc
Created October 3, 2013 01:37
Show Gist options
  • Save josephcc/6803312 to your computer and use it in GitHub Desktop.
Save josephcc/6803312 to your computer and use it in GitHub Desktop.
PSCRIPT = ../../data/scripts/
FSYMS = ../../data/pyfst_demo/ascii.syms
FTRAIN_TXT = ../../data/data/nc10k.train.txt
FDEV_TXT = ../../data/data/nc10k.dev.txt
FTRAIN_FST = nc10k.train.fst
FDEV_FST = nc10k.dev.fst
ASYMS = --isymbols=$(FSYMS) --osymbols=$(FSYMS)
AOPT = fstrmepsilon| fstdeterminize
AWGT = fstprint $(ASYMS) | $(PSCRIPT)/weight.awk| fstcompile $(ASYMS)
AEVL = fstshortestpath | fsttopsort | fstprint $(ASYMS) | $(PSCRIPT)/outtxtfst2tokens.py
APDF = fstdraw $(ASYMS) -portrait | grep -v "\\\\:\\\\" | dot -Tpdf
.PHONY: clean
clean:
rm -f *.log *.pdf q*.fst *.out.txt
super-clean: clean
rm -f *.fst *.txtfst *.txt
q%.txtfst: q%.py
python $?
q%.pdf: q%.fst
fstdraw $(ASYMS) -portrait $? | grep -v "\\\\:\\\\" | dot -Tpdf > $@
q%.orig.pdf:
python q$*.py
fstcompile $(ASYMS) q$*.txtfst > q$*.orig.fst
fstdraw $(ASYMS) -portrait q$*.orig.fst | grep -v "\\\\:\\\\" | dot -Tpdf > $@
q%.fst: q%.txtfst
fstcompile ${ASYMS} $? | fstclosure | $(AOPT) > $*.1.fst
fstminimize $*.1.fst $*.2.fst && cat $*.2.fst | $(AWGT) > $@ || cat $*.1.fst | $(AWGT) > $@
rm -f $*.1.fst $*.2.fst
q%.log: q%.train.out.txt q%.dev.out.txt
$(PSCRIPT)/score.py $(FTRAIN_TXT) q$*.train.out.txt $(FDEV_TXT) q$*.dev.out.txt > $@
rm -f train dev
q%.train.out.txt: input q%.fst
command time fstcompose $(FTRAIN_FST) q$*.fst | $(AEVL) > $@
q%.dev.out.txt: input q%.fst
command time fstcompose $(FDEV_FST) q$*.fst | $(AEVL) > $@
q%.test.out.txt: q%.fst test.fst
command time fstcompose test.fst q$*.fst | $(AEVL) > $@
q%.test.pdf: q%.fst test.fst
command time fstcompose test.fst q$*.fst | $(APDF) > $@
.PHONY: input
input: $(FTRAIN_FST) $(FDEV_FST)
$(FTRAIN_FST): $(FTRAIN_TXT)
${PSCRIPT}/text2txtfst.py < $? | fstcompile $(ASYMS) > $@
$(FDEV_FST): $(FDEV_TXT)
${PSCRIPT}/text2txtfst.py < $? | fstcompile $(ASYMS) > $@
.PHONY: test_input
test.fst:
echo a ab New York a. ab. a . . ..
echo a ab New York a. ab. a . . .. | ${PSCRIPT}/text2txtfst.py | fstcompile $(ASYMS) > $@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment