Examples of TropicalSemiring


Examples of edu.cmu.sphinx.fst.semiring.TropicalSemiring

                    .println("You need to provide both the input binary openfst model");
            System.err.println("and the output serialized java fst model.");
            System.exit(1);
        }

        Fst fst = Convert.importFst(args[0], new TropicalSemiring());

        // Serialize the java fst model to disk
        System.out.println("Saving as binary java fst model...");
        try {
            fst.saveModel(args[1]);
View Full Code Here

Examples of edu.cmu.sphinx.fst.semiring.TropicalSemiring

     * @param entry
     *            the input vector
     * @return the created fst
     */
    private Fst entryToFSA(ArrayList<String> entry) {
        TropicalSemiring ts = new TropicalSemiring();
        Fst efst = new Fst(ts);

        State s = new State(ts.zero());
        efst.addState(s);
        efst.setStart(s);

        // Build the basic FSA
        for (int i = 0; i < entry.size() + 1; i++) {
            s = new State(ts.zero());
            efst.addState(s);
            if (i >= 1) {
                int symIndex = Utils.getIndex(g2pmodel.getIsyms(),
                        entry.get(i - 1));
                efst.getState(i).addArc(new Arc(symIndex, symIndex, 0.f, s));
            } else if (i == 0) {
                int symIndex = Utils.getIndex(g2pmodel.getIsyms(), sb);
                efst.getStart().addArc(new Arc(symIndex, symIndex, 0.f, s));
            }

            if (i == entry.size()) {
                State s1 = new State(ts.zero());
                efst.addState(s1);
                int symIndex = Utils.getIndex(g2pmodel.getIsyms(), se);
                s.addArc(new Arc(symIndex, symIndex, 0.f, s1));
                s1.setFinalWeight(0.f);
            }
View Full Code Here

Examples of edu.cmu.sphinx.fst.semiring.TropicalSemiring

        String path = "algorithms/shortestpath/A.fst";
        URL url = getClass().getResource(path);
        File parent = new File(url.toURI()).getParentFile();
       
        path = new File(parent, "A").getPath();
        Fst fst = importFst(path, new TropicalSemiring());
        path = new File(parent, "nsp").getPath();
        Fst nsp = importFst(path, new TropicalSemiring());

        Fst fstNsp = NShortestPaths.get(fst, 6, true);
        assertThat(nsp, equalTo(fstNsp));
    }
View Full Code Here

Examples of edu.cmu.sphinx.fst.semiring.TropicalSemiring

        String path = "algorithms/reverse/A.fst";
        URL url = getClass().getResource(path);
        File parent = new File(url.toURI()).getParentFile();

        path = new File(parent, "A").getPath();
        Fst fst = Convert.importFst(path, new TropicalSemiring());
        path = new File(parent, "fstreverse.fst.ser").getPath();
        Fst fstB = Fst.loadModel(path);

        Fst fstReversed = Reverse.get(fst);
        assertThat(fstB, equalTo(fstReversed));
View Full Code Here

Examples of edu.cmu.sphinx.fst.semiring.TropicalSemiring

     * http://www.openfst.org/twiki/bin/view/FST/ProjectDoc
     *
     * @return the created fst
     */
    private Fst createFst() {
        TropicalSemiring ts = new TropicalSemiring();
        Fst fst = new Fst(ts);

        State s1 = new State(ts.zero());
        State s2 = new State(ts.zero());
        State s3 = new State(ts.zero());
        State s4 = new State(2.f);

        // State 0
        fst.addState(s1);
        s1.addArc(new Arc(1, 5, 1.f, s2));
View Full Code Here

Examples of edu.cmu.sphinx.fst.semiring.TropicalSemiring

     * http://www.openfst.org/twiki/bin/view/FST/ProjectDoc
     *
     * @return the created fst
     */
    private Fst createPi() {
        TropicalSemiring ts = new TropicalSemiring();
        Fst fst = new Fst(ts);
        State s1 = new State(ts.zero());
        State s2 = new State(ts.zero());
        State s3 = new State(ts.zero());
        State s4 = new State(2.f);

        // State 0
        fst.addState(s1);
        s1.addArc(new Arc(1, 1, 1.f, s2));
View Full Code Here

Examples of edu.cmu.sphinx.fst.semiring.TropicalSemiring

     * http://www.openfst.org/twiki/bin/view/FST/ProjectDoc
     *
     * @return the created fst
     */
    private Fst createPo() {
        TropicalSemiring ts = new TropicalSemiring();
        Fst fst = new Fst(ts);

        State s1 = new State(ts.zero());
        State s2 = new State(ts.zero());
        State s3 = new State(ts.zero());
        State s4 = new State(2.f);

        // State 0
        fst.addState(s1);
        s1.addArc(new Arc(5, 5, 1.f, s2));
View Full Code Here

Examples of edu.cmu.sphinx.fst.semiring.TropicalSemiring

        String path = "algorithms/compose/fstcompose.fst.ser";
        URL url = getClass().getResource(path);                     
        File parent = new File(url.toURI()).getParentFile();

        path = new File(parent, "A").getPath();
        Fst fstA = importFst(path, new TropicalSemiring());
        path = new File(parent, "B").getPath();
        Fst fstB = importFst(path, new TropicalSemiring());
        path = new File(parent, "fstcompose.fst.ser").getPath();
        Fst composed = Fst.loadModel(path);

        Fst fstComposed = Compose.get(fstA, fstB, new TropicalSemiring());
        assertThat(composed, equalTo(fstComposed));
    }
View Full Code Here

Examples of edu.cmu.sphinx.fst.semiring.TropicalSemiring

    public void testCompose() throws NumberFormatException, IOException, URISyntaxException {
        URL url = getClass().getResource("algorithms/composeeps/A.fst.txt");
        File parent = new File(url.toURI()).getParentFile();

        String path = new File(parent, "A").getPath();
        Fst fstA = importFst(path, new TropicalSemiring());
        path = new File(parent, "B").getPath();
        Fst fstB = importFst(path, new TropicalSemiring());
        path = new File(parent, "fstcomposeeps").getPath();
        Fst fstC = importFst(path, new TropicalSemiring());

        Fst fstComposed = get(fstA, fstB, new TropicalSemiring());
        assertThat(fstC, equalTo(fstComposed));
    }
View Full Code Here

Examples of edu.cmu.sphinx.fst.semiring.TropicalSemiring

        String path = "algorithms/connect/fstconnect.fst.ser";
        URL url = getClass().getResource(path);
        File parent = new File(url.toURI()).getParentFile();

        path = new File(parent, "A").getPath();
        Fst fst = importFst(path, new TropicalSemiring());
        path = new File(parent, "fstconnect.fst.ser").getPath();
        Fst connectSaved = Fst.loadModel(path);
       
        apply(fst);
        assertThat(connectSaved, equalTo(fst));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.