Exemple #1
0
  /**
   * Returns the string of words for this token, each with the starting sample number as the
   * timestamp. This method assumes that the word tokens come after the unit and hmm tokens.
   *
   * @return the string of words, each with the starting sample number
   */
  private String getTimedWordTokenLastPath(Token token, boolean wantFiller) {
    StringBuilder sb = new StringBuilder();
    Word word = null;
    Data lastFeature = null;
    Data lastWordFirstFeature = null;

    while (token != null) {
      if (token.isWord()) {
        if (word != null && lastFeature != null) {
          if (wantFiller || !word.isFiller()) {
            addWord(sb, word, (FloatData) lastFeature, (FloatData) lastWordFirstFeature);
          }
          word = token.getWord();
          lastWordFirstFeature = lastFeature;
        }
        word = token.getWord();
      }
      Data feature = token.getData();
      if (feature != null) {
        lastFeature = feature;
        if (lastWordFirstFeature == null) {
          lastWordFirstFeature = lastFeature;
        }
      }
      token = token.getPredecessor();
    }

    return sb.toString();
  }
Exemple #2
0
  /**
   * Returns the string of words (with timestamp) for this token. This method assumes that the word
   * tokens come before other types of token.
   *
   * @param wantFiller true if we want filler words, false otherwise
   * @return the string of words
   */
  private String getTimedWordPath(Token token, boolean wantFiller) {
    StringBuilder sb = new StringBuilder();

    // get to the first emitting token
    while (token != null && !token.isEmitting()) {
      token = token.getPredecessor();
    }

    if (token != null) {
      Data lastWordFirstFeature = token.getData();
      Data lastFeature = lastWordFirstFeature;
      token = token.getPredecessor();

      while (token != null) {
        if (token.isWord()) {
          Word word = token.getWord();
          if (wantFiller || !word.isFiller()) {
            addWord(sb, word, (FloatData) lastFeature, (FloatData) lastWordFirstFeature);
          }
          lastWordFirstFeature = lastFeature;
        }
        Data feature = token.getData();
        if (feature != null) {
          lastFeature = feature;
        }
        token = token.getPredecessor();
      }
    }
    return sb.toString();
  }