Skip to content

Instantly share code, notes, and snippets.

@stevenbedrick
Created December 9, 2014 23:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevenbedrick/3cd157b16536a544bb9b to your computer and use it in GitHub Desktop.
Save stevenbedrick/3cd157b16536a544bb9b to your computer and use it in GitHub Desktop.
OpenFST: ASCII symbol table to binary symbol table
#include <fst/fst.h>
#include <fst/symbol-table.h>
/*
Converts ASCII OpenFST symbol tables to binary symbol tables. To compile:
g++ -I/usr/local/lib/fst -L/usr/local/lib/fst -lfst -o convert_syms convert_syms.cc
Then, run:
./convert_syms ascii.syms.txt asci.syms.bin
No promises made vis-a-vis security, error handling, etc. etc.
Written by Steven Bedrick (bedricks@ohsu.edu)
*/
using fst::SymbolTable;
int main (int argc, char const *argv[])
{
if (argc != 3) {
cout << "Usage: ./convert_syms $INFILE $OUTFILE" << endl;
exit(1);
}
SymbolTable *syms;
fst::SymbolTableTextOptions opts;
syms = SymbolTable::ReadText(argv[1], opts);
cout << "There are " << syms->NumSymbols() << " symbols in " << argv[1] << endl;
syms->Write(argv[2]);
return 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment