Examples of FeatureSet


Examples of com.sun.speech.freetts.FeatureSet

     * 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");
  }
    }
View Full Code Here

Examples of com.sun.speech.freetts.FeatureSet

     * @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);
    }
View Full Code Here

Examples of com.sun.speech.freetts.FeatureSet

     *
     * @param word the word to set
     */
    public void setLastWord(String word) {
  Item lastItem = relation.getTail();
  FeatureSet featureSet = lastItem.getFeatures();
  featureSet.setString("name", word);
    }
View Full Code Here

Examples of com.sun.speech.freetts.FeatureSet

 
  for (tokenItem = tokenRelation.getHead();
       tokenItem != null;
       tokenItem = tokenItem.getNext()) {

      FeatureSet featureSet = tokenItem.getFeatures();
      String tokenVal = featureSet.getString("name");
     
      // convert the token into a list of words
      tokenToWords(tokenVal);
  }
    }
View Full Code Here

Examples of com.sun.speech.freetts.FeatureSet

     *                  same as the one in called "name" in flite
     *
     */
    private void tokenToWords(String tokenVal) {

  FeatureSet tokenFeatures = tokenItem.getFeatures();
  String itemName = tokenFeatures.getString("name");
  int tokenLength = tokenVal.length();

  if (tokenFeatures.isPresent("phones")) {
      wordRelation.addWord(tokenVal);

  } else if ((tokenVal.equals("a") || tokenVal.equals("A")) &&
                ((tokenItem.getNext() == null) ||
                 !(tokenVal.equals(itemName)) ||
                 !(((String) tokenItem.findFeature("punc")).equals("")))) {
      /* if A is a sub part of a token, then its ey not ah */
      wordRelation.addWord("_a");

  } else if (matches(alphabetPattern, tokenVal)) {

      if (matches(romanNumbersPattern, tokenVal)) {
   
    /* XVIII */
    romanToWords(tokenVal);
   
      } else if (matches(illionPattern, tokenVal) &&
           matches(usMoneyPattern,
             (String) tokenItem.findFeature("p.name"))) {
    /* $ X -illion */
    wordRelation.addWord(tokenVal);
    wordRelation.addWord("dollars");     
   
      } else if (matches(drStPattern, tokenVal)) {
   
    /* St Andrew's St, Dr King Dr */
    drStToWords(tokenVal);
   
      } else if (tokenVal.equals("Mr")) {
   
    tokenItem.getFeatures().setString("punc", "");
    wordRelation.addWord("mister");
   
      } else if (tokenVal.equals("Mrs")) {
   
    tokenItem.getFeatures().setString("punc", "");
    wordRelation.addWord("missus");
   
      } else if (tokenLength == 1
           && isUppercaseLetter(tokenVal.charAt(0))
           && ((String)tokenItem.findFeature("n.whitespace")).equals(" ")
           && isUppercaseLetter
           (((String) tokenItem.findFeature("n.name")).charAt(0))) {
   
    tokenFeatures.setString("punc", "");
    String aaa = tokenVal.toLowerCase();
    if (aaa.equals("a")) {
        wordRelation.addWord("_a");
    } else {
        wordRelation.addWord(aaa);
    }
      } else if (isStateName(tokenVal)) {
    /*
      The name of a US state
      isStateName() has already added the full name of the
      state, so we're all set.
    */
      } else if (tokenLength > 1 && !isPronounceable(tokenVal)) {
    /* Need common exception list */
    /* unpronouncable list of alphas */
    NumberExpander.expandLetters
        (tokenVal, wordRelation);
   
      } else {
    /* just a word */
    wordRelation.addWord(tokenVal.toLowerCase());
      }
     
  } else if (matches(dottedAbbrevPattern, tokenVal)) {
     
      /* U.S.A. */
      // remove all dots
      String aaa = Utilities.deleteChar(tokenVal, '.');
      NumberExpander.expandLetters(aaa, wordRelation);
     
  } else if (matches(commaIntPattern, tokenVal)) {
     
      /* 99,999,999 */
      String aaa = Utilities.deleteChar(tokenVal, ',');
      NumberExpander.expandReal(aaa, wordRelation);
     
  } else if (matches(sevenPhoneNumberPattern, tokenVal)) {
     
      /* 234-3434  telephone numbers */
      int dashIndex = tokenVal.indexOf('-');
      String aaa = tokenVal.substring(0, dashIndex);
      String bbb = tokenVal.substring(dashIndex+1);
     
      NumberExpander.expandDigits(aaa, wordRelation);
      wordRelation.addBreak();
      NumberExpander.expandDigits(bbb, wordRelation);
     
  } else if (matchesPartPhoneNumber(tokenVal)) {
     
      /* part of a telephone number */
      String punctuation = (String) tokenItem.findFeature("punc");
      if (punctuation.equals("")) {
    tokenItem.getFeatures().setString("punc", ",");
      }
      NumberExpander.expandDigits(tokenVal, wordRelation);
      wordRelation.addBreak();
   
  } else if (matches(numberTimePattern, tokenVal)) {
     
      /* 12:35 */
      int colonIndex = tokenVal.indexOf(':');
      String aaa = tokenVal.substring(0, colonIndex);
      String bbb = tokenVal.substring(colonIndex+1);
     
      NumberExpander.expandNumber(aaa, wordRelation);
      if (!(bbb.equals("00"))) {
    NumberExpander.expandID(bbb, wordRelation);
      }
     
  } else if (matches(digits2DashPattern, tokenVal)) {
     
      /* 999-999-999 */
      digitsDashToWords(tokenVal);
     
  } else if (matches(digitsPattern, tokenVal)) {
     
      digitsToWords(tokenVal);
     
  } else if (tokenLength == 1
       && isUppercaseLetter(tokenVal.charAt(0))
       && ((String)tokenItem.findFeature("n.whitespace")).equals
                   (" ")
       && isUppercaseLetter
       (((String) tokenItem.findFeature("n.name")).charAt(0))) {
     
      tokenFeatures.setString("punc", "");
      String aaa = tokenVal.toLowerCase();
      if (aaa.equals("a")) {
    wordRelation.addWord("_a");
      } else {
    wordRelation.addWord(aaa);
View Full Code Here

Examples of com.sun.speech.freetts.FeatureSet

     * Convert the given digit token into (word) Items in the WordRelation.
     *
     * @param tokenVal  the digit string
     */
    private void digitsToWords(String tokenVal) {
  FeatureSet featureSet = tokenItem.getFeatures();
  String nsw = "";
  if (featureSet.isPresent("nsw")) {
      nsw = featureSet.getString("nsw");
  }

  if (nsw.equals("nide")) {
      NumberExpander.expandID(tokenVal, wordRelation);
  } else {
      String rName = featureSet.getString("name");
      String digitsType = null;
     
      if (tokenVal.equals(rName)) {
    digitsType = (String) cart.interpret(tokenItem);
      } else {
    featureSet.setString("name", tokenVal);
    digitsType = (String) cart.interpret(tokenItem);
    featureSet.setString("name", rName);
      }
     
      if (digitsType.equals("ordinal")) {
    NumberExpander.expandOrdinal(tokenVal, wordRelation);
      } else if (digitsType.equals("digits")) {
View Full Code Here

Examples of com.sun.speech.freetts.FeatureSet

  } else {
      street = "drive";
      saint = "doctor";
  }
 
  FeatureSet featureSet = tokenItem.getFeatures();
  String punctuation = featureSet.getString("punc");

  String featPunctuation = (String) tokenItem.findFeature("punc");

  if (tokenItem.getNext() == null ||
      punctuation.indexOf(',') != -1) {
      wordRelation.addWord(street);
  } else if (featPunctuation.equals(",")) {
      wordRelation.addWord(saint);
  } else {
      String pName = (String) tokenItem.findFeature("p.name");
      String nName = (String) tokenItem.findFeature("n.name");

      char p0 = pName.charAt(0);
      char n0 = nName.charAt(0);

      if (isUppercaseLetter(p0) && isLowercaseLetter(n0)) {
    wordRelation.addWord(street);
      } else if (NumberExpander.isDigit(p0) && isLowercaseLetter(n0)) {
    wordRelation.addWord(street);
      } else if (isLowercaseLetter(p0) && isUppercaseLetter(n0)) {
    wordRelation.addWord(saint);
      } else {
    String whitespace = (String) tokenItem.findFeature("n.whitespace");
    if (whitespace.equals(" ")) {
        wordRelation.addWord(saint);
    } else {
        wordRelation.addWord(street);
    }
      }
  }

  if (punctuation != null && punctuation.equals(".")) {
      featureSet.setString("punc", "");
  }
    }
View Full Code Here

Examples of com.sun.speech.freetts.FeatureSet

  int index = tokenVal.indexOf('-');
  String aaa = tokenVal.substring(0, index);
  String bbb = tokenVal.substring(index+1, tokenVal.length());

  if (matches(digitsPattern, aaa) && matches(digitsPattern, bbb)) {
      FeatureSet featureSet = tokenItem.getFeatures();
      featureSet.setString("name", aaa);
      tokenToWords(aaa);
      wordRelation.addWord("to");
      featureSet.setString("name", bbb);
      tokenToWords(bbb);
      featureSet.setString("name", "");
  } else {     
      tokenToWords(aaa);
      tokenToWords(bbb);
  }
    }
View Full Code Here

Examples of com.sun.speech.freetts.FeatureSet

  }
 
  String aaa = tokenVal.substring(0, index+1);
  String bbb = tokenVal.substring(index+1, tokenLength);
 
  FeatureSet featureSet = tokenItem.getFeatures();
  featureSet.setString("nsw", "nide");
  tokenToWords(aaa);
  tokenToWords(bbb);
    }
View Full Code Here

Examples of com.sun.speech.freetts.FeatureSet

                // System.out.println("previous = " + previous);
                // System.out.println("next = " + next);
               
                int nextLength = next.length();
                FeatureSet featureSet = tokenItem.getFeatures();
               
                // check if the previous word starts with a capital letter,
                // is at least 3 letters long, is an alphabet sequence,
                // and has a comma.
                boolean previousIsCity =
                    (isUppercaseLetter(previous.charAt(0))
                     && previous.length() > 2
                     && matches(alphabetPattern, previous)
                     && tokenItem.findFeature("p.punc").equals(","));
               
                // check if next token starts with a lower case, or
                // this is the end of sentence, or if next token
                // is a period (".") or a zip code (5 or 10 digits).
                boolean nextIsGood =
                    (isLowercaseLetter(next.charAt(0))
                     || tokenItem.getNext() == null
                     || featureSet.getString("punc").equals(".")
                     || ((nextLength == 5 || nextLength == 10) &&
                         matches(digitsPattern, next)));
               
                if (previousIsCity && nextIsGood) {
                    expandState = true;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.