public String phonemise(String text,String pos,StringBuilder g2pMethod){
  String result=userdictLookup(text,pos);
  if (result != null) {
    g2pMethod.append("userdict");
    return result;
  }
  result=lexiconLookup(text,pos);
  if (result != null) {
    g2pMethod.append("lexicon");
    return result;
  }
  String normalised=MaryUtils.normaliseUnicodeLetters(text,getLocale());
  if (!normalised.equals(text)) {
    result=userdictLookup(normalised,pos);
    if (result != null) {
      g2pMethod.append("userdict");
      return result;
    }
    result=lexiconLookup(normalised,pos);
    if (result != null) {
      g2pMethod.append("lexicon");
      return result;
    }
  }
  String phones=lts.predictPronunciation(text);
  result=lts.syllabify(phones);
  if (result != null) {
    g2pMethod.append("rules");
    return result;
  }
  return null;
}

public String phonemise ( String text , String pos , StringBuilder g2pMethod ) { String result = userdictLookup ( text , pos ) ; if ( result != null ) { g2pMethod . append ( "userdict" ) ; return result ; } result = lexiconLookup ( text , pos ) ; if ( result != null ) { g2pMethod . append ( "lexicon" ) ; return result ; } String normalised = MaryUtils . normaliseUnicodeLetters ( text , getLocale ( ) ) ; if ( ! normalised . equals ( text ) ) { result = userdictLookup ( normalised , pos ) ; if ( result != null ) { g2pMethod . append ( "userdict" ) ; return result ; } result = lexiconLookup ( normalised , pos ) ; if ( result != null ) { g2pMethod . append ( "lexicon" ) ; return result ; } } String phones = lts . predictPronunciation ( text ) ; result = lts . syllabify ( phones ) ; if ( result != null ) { g2pMethod . append ( "rules" ) ; return result ; } return null ; }
phonemise the word text . this starts with a simple lexicon lookup , followed by some heuristics , and finally applies letter - to - sound rules if nothing else was successful .
