Пример #1
0
        private static void exportFst(Fst fst, string text)
        {
            FileWriter  fileWriter  = new FileWriter(text);
            PrintWriter printWriter = new PrintWriter(fileWriter);
            State       start       = fst.getStart();

            printWriter.println(new StringBuilder().append(start.getId()).append("\t").append(start.getFinalWeight()).toString());
            int numStates = fst.getNumStates();

            for (int i = 0; i < numStates; i++)
            {
                State state = fst.getState(i);
                if (state.getId() != fst.getStart().getId())
                {
                    printWriter.println(new StringBuilder().append(state.getId()).append("\t").append(state.getFinalWeight()).toString());
                }
            }
            string[] isyms = fst.getIsyms();
            string[] osyms = fst.getOsyms();
            numStates = fst.getNumStates();
            for (int j = 0; j < numStates; j++)
            {
                State state2  = fst.getState(j);
                int   numArcs = state2.getNumArcs();
                for (int k = 0; k < numArcs; k++)
                {
                    Arc    arc   = state2.getArc(k);
                    string text2 = (isyms == null) ? Integer.toString(arc.getIlabel()) : isyms[arc.getIlabel()];
                    string text3 = (osyms == null) ? Integer.toString(arc.getOlabel()) : osyms[arc.getOlabel()];
                    printWriter.println(new StringBuilder().append(state2.getId()).append("\t").append(arc.getNextState().getId()).append("\t").append(text2).append("\t").append(text3).append("\t").append(arc.getWeight()).toString());
                }
            }
            printWriter.close();
        }
Пример #2
0
 public static void export(Fst fst, string basename)
 {
     Convert.exportSymbols(fst.getIsyms(), new StringBuilder().append(basename).append(".input.syms").toString());
     Convert.exportSymbols(fst.getOsyms(), new StringBuilder().append(basename).append(".output.syms").toString());
     Convert.exportFst(fst, new StringBuilder().append(basename).append(".fst.txt").toString());
 }