Package edu.cmu.sphinx.linguist

Examples of edu.cmu.sphinx.linguist.SearchState


    /** Gets the initial grammar node from the linguist and creates a GrammarNodeToken */
    protected void localStart() {
        currentFrameNumber = 0;
        curTokensScored.value = 0;
        ActiveList newActiveList = activeListFactory.newInstance();
        SearchState state = linguist.getSearchGraph().getInitialState();
        newActiveList.add(new Token(state, currentFrameNumber));
        activeList = newActiveList;

        growBranches();
    }
View Full Code Here


     * Collects the next set of emitting tokens from a token and accumulates them in the active or result lists
     *
     * @param token the token to collect successors from
     */
    protected void collectSuccessorTokens(Token token) {
        SearchState state = token.getSearchState();
        // If this is a final state, add it to the final list
        if (token.isFinal()) {
            resultList.add(token);
        }
        if (token.getScore() < threshold) {
            return;
        }
        if (state instanceof WordSearchState
                && token.getScore() < wordThreshold) {
            return;
        }
        SearchStateArc[] arcs = state.getSuccessors();
        // For each successor
        // calculate the entry score for the token based upon the
        // predecessor token score and the transition probabilities
        // if the score is better than the best score encountered for
        // the SearchState and frame then create a new token, add
        // it to the lattice and the SearchState.
        // If the token is an emitting token add it to the list,
        // otherwise recursively collect the new tokens successors.
        for (SearchStateArc arc : arcs) {
            SearchState nextState = arc.getState();
            // We're actually multiplying the variables, but since
            // these come in log(), multiply gets converted to add
            float logEntryScore = token.getScore() + arc.getProbability();
            if (wantEntryPruning) { // false by default
                if (logEntryScore < threshold) {
View Full Code Here

     *
     * @param t the token to check
     * @return true if we've visited the search state since the last frame
     */
    private boolean isVisited(Token t) {
        SearchState curState = t.getSearchState();

        t = t.getPredecessor();

        while (t != null && !t.isEmitting()) {
            if (curState.equals(t.getSearchState())) {
                return true;
            }
            t = t.getPredecessor();
        }
        return false;
View Full Code Here

   *            the token to test
   * @return <code>true</code> if the token should be expanded
   */
  private boolean skewPruneHMM(Token t) {
    boolean keep = true;
    SearchState ss = t.getSearchState();
    if (ss instanceof HMMSearchState) {
      if (!t.isEmitting()) {
        // HMMSearchState hss = (HMMSearchState) ss;
        Token lastToken = skewMap.get(ss);
        if (lastToken != null) {
View Full Code Here

   *            the token to test
   * @return <code>true</code> if the token should be expanded
   */
  private boolean skewPruneWord(Token t) {
    boolean keep = true;
    SearchState ss = t.getSearchState();
    if (ss instanceof WordSearchState) {
      Token lastToken = skewMap.get(ss);
      if (lastToken != null) {
        int lastFrame = lastToken.getFrameNumber();
        if (t.getFrameNumber() - lastFrame > skew
View Full Code Here

        // System.out.println(Utilities.pad(level * 2) + state);
        if (newStates.length > maxSuccessors) {
            maxSuccessors = newStates.length;
        }
        for (SearchStateArc newState : newStates) {
            SearchState ns = newState.getState();
            if (ns.isEmitting()) {
                totalEmittingStates++;
                activeList.add(ns);
            } else if (!ns.isFinal()) {
                totalNonEmittingStates++;
                activeList.add(ns);
                if (details && ns.isFinal()) {
                    System.out.println("result " + ns.toPrettyString());
                }
                expandState(level + 1, activeList, ns);
            } else {
                totalFinalStates++;
            }
View Full Code Here

    public String getWordUnitPath() {
        StringBuilder sb = new StringBuilder();
        Token token = this;

        while (token != null) {
            SearchState searchState = token.getSearchState();
            if (searchState instanceof WordSearchState) {
                WordSearchState wordState = (WordSearchState) searchState;
                Word word = wordState.getPronunciation().getWord();
                sb.insert(0, ' ' + word.getSpelling());
            } else if (searchState instanceof UnitSearchState) {
View Full Code Here

     *
     * @param t the token to track
     */
    public void add(Token t) {
        numTokens++;
        SearchState s = t.getSearchState();

        if (s instanceof WordSearchState) {
            numWords++;
        } else if (s instanceof UnitSearchState) {
            numUnits++;
View Full Code Here

    if (token == null)
      throw new Exception("Best token not found!");

    do {
      FloatData feature = (FloatData) token.getData();
      SearchState ss = token.getSearchState();

      if (!(ss instanceof HMMSearchState && ss.isEmitting())) {
        token = token.getPredecessor();
        continue;
      }

      componentScore = token.calculateComponentScore(feature);
View Full Code Here

TOP

Related Classes of edu.cmu.sphinx.linguist.SearchState

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.