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

Examples of edu.cmu.sphinx.linguist.language.grammar.GrammarNode


            Set<GrammarNode> vistedNodes = new HashSet<GrammarNode>();
            Set<Unit> unitSet = new HashSet<Unit>();

            GrammarArc[] arcs = node.getSuccessors();
            for (GrammarArc arc : arcs) {
                GrammarNode nextNode = arc.getGrammarNode();
                collectNextUnits(nextNode, vistedNodes, unitSet);
            }
            int[] nextUnits = new int[unitSet.size()];
            int index = 0;
            for (Unit unit : unitSet) {
View Full Code Here


                unitSet.add(pronunciation.getUnits()[0]);
            }
        } else {
            GrammarArc[] arcs = thisNode.getSuccessors();
            for (GrammarArc arc : arcs) {
                GrammarNode nextNode = arc.getGrammarNode();
                collectNextUnits(nextNode, vistedNodes, unitSet);
            }
        }
    }
View Full Code Here

         */
        GrammarArc[] filter(GrammarArc[] arcs, int nextBase) {
            if (nextBase != ANY) {
                List<GrammarArc> list = new ArrayList<GrammarArc>();
                for (GrammarArc arc : arcs) {
                    GrammarNode node = arc.getGrammarNode();
                    if (hasEntryContext(node, nextBase)) {
                        list.add(arc);
                    }
                }
                arcs = list.toArray(new GrammarArc[list.size()]);
View Full Code Here

     *
     */
    protected void addStartingPath(GrammarNode initialNode) {
        // guarantees a starting path into the initial node by
        // adding an empty left context to the starting gstate
        GrammarNode node = initialNode;
        GState gstate = getGState(node);
        gstate.addLeftContext(UnitContext.SILENCE);
    }
View Full Code Here

     * Finds the starting state
     *
     * @return the starting state
     */
    protected SentenceHMMState findStartingState() {
        GrammarNode node = grammar.getInitialNode();
        GState gstate = getGState(node);
        return gstate.getEntryPoint();
    }
View Full Code Here

      Set<GrammarNode> vistedNodes = new HashSet<GrammarNode>();
      Set<Unit> unitSet = new HashSet<Unit>();

      GrammarArc[] arcs = node.getSuccessors();
      for (GrammarArc arc : arcs) {
        GrammarNode nextNode = arc.getGrammarNode();
        collectNextUnits(nextNode, vistedNodes, unitSet);
      }
      int[] nextUnits = new int[unitSet.size()];
      int index = 0;
      for (Unit unit : unitSet) {
View Full Code Here

        unitSet.add(pronunciation.getUnits()[0]);
      }
    } else {
      GrammarArc[] arcs = thisNode.getSuccessors();
      for (GrammarArc arc : arcs) {
        GrammarNode nextNode = arc.getGrammarNode();
        collectNextUnits(nextNode, vistedNodes, unitSet);
      }
    }
  }
View Full Code Here

     */
    GrammarArc[] filter(GrammarArc[] arcs, int nextBase) {
      if (nextBase != ANY) {
        List<GrammarArc> list = new ArrayList<GrammarArc>();
        for (GrammarArc arc : arcs) {
          GrammarNode node = arc.getGrammarNode();
          if (hasEntryContext(node, nextBase)) {
            list.add(arc);
          }
        }
        arcs = list.toArray(new GrammarArc[list.size()]);
View Full Code Here

     */
    private static List<GrammarNode> getNextGrammarNodesWithWords(GrammarNode node) {
        List<GrammarNode> list = new ArrayList<GrammarNode>();

        for (GrammarArc arc : node.getSuccessors()) {
            GrammarNode gnode = arc.getGrammarNode();
            if (gnode.getAlternatives().length == 0) {
                if (gnode.isFinalNode()) {
                    list.add(gnode);
                } else {
                    list.addAll(getNextGrammarNodesWithWords(gnode));
                }
            } else {
View Full Code Here

     * @return the first and last GrammarNodes of the network
     */
    private GrammarGraph processRuleSequence(JSGFRuleSequence ruleSequence)
            throws JSGFGrammarException {

        GrammarNode startNode = null;
        GrammarNode endNode = null;
        logger.fine("parseRuleSequence: " + ruleSequence);

        List<JSGFRule> rules = ruleSequence.getRules();

        GrammarNode lastGrammarNode = null;

        // expand and connect each rule in the sequence serially
        for (int i = 0; i < rules.size(); i++) {
            JSGFRule rule = rules.get(i);
            GrammarGraph newNodes = processRule(rule);

            // first node
            if (i == 0) {
                startNode = newNodes.getStartNode();
            }

            // last node
            if (i == (rules.size() - 1)) {
                endNode = newNodes.getEndNode();
            }

            if (i > 0) {
                lastGrammarNode.add(newNodes.getStartNode(), 0.0f);
            }
            lastGrammarNode = newNodes.getEndNode();
        }

        return new GrammarGraph(startNode, endNode);
View Full Code Here

TOP

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

Copyright © 2018 www.massapicom. 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.