Package edu.cmu.sphinx.linguist.language.grammar

Source Code of edu.cmu.sphinx.linguist.language.grammar.FSTGrammarTest

package edu.cmu.sphinx.linguist.language.grammar;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasSize;

import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;

import org.testng.annotations.Test;

import edu.cmu.sphinx.linguist.acoustic.UnitManager;
import edu.cmu.sphinx.linguist.dictionary.Dictionary;
import edu.cmu.sphinx.linguist.dictionary.FastDictionary;


public class FSTGrammarTest {

    @Test
    public void testForcedAlignerGrammar() throws IOException, URISyntaxException {
        URL dictionaryUrl = getClass().getResource("FSTGrammarTest.dic");
        URL noisedictUrl = getClass()
                .getResource("/edu/cmu/sphinx/models/acoustic/wsj/noisedict");

        Dictionary dictionary = new FastDictionary(dictionaryUrl,
                                                   noisedictUrl,
                                                   null,
                                                   false,
                                                   null,
                                                   false,
                                                   false,
                                                   new UnitManager());

        URL url = getClass().getResource("FSTGrammarTest.gram");
        FSTGrammar grammar = new FSTGrammar(new File(url.toURI()).getPath(),
                                            true,
                                            true,
                                            true,
                                            true,
                                            dictionary);
        grammar.allocate();
        assertThat(grammar.getGrammarNodes(), hasSize(14));
    }
}
TOP

Related Classes of edu.cmu.sphinx.linguist.language.grammar.FSTGrammarTest

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.