示例#1
0
 /**
  * Adds a word as an Item to this WordRelation object.
  *
  * @param word the word to add
  */
 public void addWord(String word) {
   Item tokenItem = tokenToWords.getTokenItem();
   Item wordItem = tokenItem.createDaughter();
   FeatureSet featureSet = wordItem.getFeatures();
   featureSet.setString("name", word);
   relation.appendItem(wordItem);
 }
示例#2
0
 /** Adds a break as a feature to the last item in the list. */
 public void addBreak() {
   Item wordItem = (Item) relation.getTail();
   if (wordItem != null) {
     FeatureSet featureSet = wordItem.getFeatures();
     featureSet.setString("break", "1");
   }
 }
示例#3
0
 /**
  * Returns the float feature of the last Item in the named Relation.
  *
  * @return the float feature of the last Item in the named Relation, or -1 otherwise
  */
 private float getLastFloat(String relationName, String feature) {
   float duration = -1;
   Relation relation;
   if ((relation = getRelation(relationName)) != null) {
     Item lastItem = relation.getTail();
     if (lastItem != null) {
       duration = lastItem.getFeatures().getFloat(feature);
     }
   }
   return duration;
 }
示例#4
0
  /**
   * Sets the token list for this utterance. Note that this could be optimized by turning the token
   * list directly into the token relation.
   *
   * @param tokenList the tokenList
   */
  private void setTokenList(List tokenList) {
    setInputText(tokenList);

    Relation relation = createRelation(Relation.TOKEN);
    for (Iterator i = tokenList.iterator(); i.hasNext(); ) {
      Token token = (Token) i.next();
      String tokenWord = token.getWord();

      if (tokenWord != null && tokenWord.length() > 0) {
        Item item = relation.appendItem();

        FeatureSet featureSet = item.getFeatures();
        featureSet.setString("name", tokenWord);
        featureSet.setString("whitespace", token.getWhitespace());
        featureSet.setString("prepunctuation", token.getPrepunctuation());
        featureSet.setString("punc", token.getPostpunctuation());
        featureSet.setString("file_pos", String.valueOf(token.getPosition()));
        featureSet.setString("line_number", String.valueOf(token.getLineNumber()));
      }
    }
  }
示例#5
0
 /**
  * Sets the last Item in this WordRelation to the given word.
  *
  * @param word the word to set
  */
 public void setLastWord(String word) {
   Item lastItem = relation.getTail();
   FeatureSet featureSet = lastItem.getFeatures();
   featureSet.setString("name", word);
 }