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.TextDictionary; public class FSTGrammarTest { @Test public void testForcedAlignerGrammar() throws IOException, URISyntaxException { URL dictionaryUrl = getClass().getResource("FSTGrammarTest.dic"); URL noisedictUrl = getClass() .getResource("/edu/cmu/sphinx/models/en-us/en-us/noisedict"); Dictionary dictionary = new TextDictionary(dictionaryUrl, noisedictUrl, null, null, 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)); } }