Exemplo n.º 1
0
 public static void main(String[] args) {
   LetterToSound text = LetterToSound.getInstance();
   System.out.println(Arrays.asList(text.getPhones("laggin", "n")));
   System.out.println(Arrays.asList(text.getPhones("dragon", "n")));
   System.out.println(Arrays.asList(text.getPhones("hello", "n")));
   // System.out.println(Arrays.asList(text.getPhones("antelope", "n")));
 }
Exemplo n.º 2
0
  /**
   * Compares this LTS to another for debugging purposes.
   *
   * @param other the other LTS to compare to
   * @return <code>true</code> if these are equivalent
   */
  public boolean compare(LetterToSound other) {

    // compare letter index table
    //
    for (Iterator i = letterIndex.keySet().iterator(); i.hasNext(); ) {
      String key = (String) i.next();
      Integer thisIndex = (Integer) letterIndex.get(key);
      Integer otherIndex = (Integer) other.letterIndex.get(key);
      if (!thisIndex.equals(otherIndex)) {
        if (RiTa.PRINT_LTS_INFO) System.err.println("[WARN] LTSengine -> Bad index: " + key);
        return false;
      }
    }

    // compare states
    //
    for (int i = 0; i < stateMachine.length; i++) {
      State state = getState(i);
      State otherState = other.getState(i);
      if (!state.compare(otherState)) {
        if (RiTa.PRINT_LTS_INFO) System.err.println("[WARN] LTSengine -> Bad state: " + i);
        return false;
      }
    }

    return true;
  }