NamesConversion nc = new NamesConversion(); nc.buildPhoneConversion(MMFfile); nc.buildWordConversion(lexFile); System.out.println("converting phones in MMF to "+MMFfile+".conv"); nc.convertMMF(MMFfile); if (lexFile!=null) { System.out.println("converting phones and words in lexicon to "+lexFile+".conv"); nc.convertLexicon(lexFile); nc.convertLexicon(fillerFile); nc.convertWordGrammar(gramFile);
void buildPhoneConversion(String MMFfile) { try { BufferedReader bf = new BufferedReader(new FileReader(MMFfile)); String s; for (;;) { s=bf.readLine(); if (s==null) break; int i=s.indexOf("~h"); if (i>=0) { i=s.indexOf('"'); int j = s.lastIndexOf('"'); String nom = s.substring(i+1,j); split3ph(nom); if (left!=null) addInConv(left,phoneConv); if (base!=null) addInConv(base,phoneConv); if (right!=null) addInConv(right,phoneConv); } } bf.close(); } catch (IOException e) { e.printStackTrace(); } } void buildWordConversion(String lexFile) {
String conv3ph() { String rep; if (left!=null) { rep=conv1ph(left)+ '-'; } else rep=""; rep+=conv1ph(base); if (right!=null) { rep+= '+' +conv1ph(right); } if (rep.equals("null")) { System.err.println("detson error "+left+ ' ' +base+ ' ' +right); System.exit(1); } return rep; } String conv1ph(String p) {
void convertMMF(String MMFfile) { try { BufferedReader bf = new BufferedReader(new FileReader(MMFfile)); PrintWriter pf = new PrintWriter(new FileWriter(MMFfile+".conv")); String s; for (;;) { s=bf.readLine(); if (s==null) break; int i=s.indexOf("~h"); if (i>=0) { i=s.indexOf('"'); int j = s.lastIndexOf('"'); String nom = s.substring(i+1,j); split3ph(nom); String newnom = conv3ph(); pf.println("~h \""+newnom+ '\"'); } else pf.println(s); } pf.close(); bf.close(); } catch (IOException e) { e.printStackTrace(); } }
void buildWordConversion(String lexFile) { try { BufferedReader bf = new BufferedReader(new FileReader(lexFile)); String s; for (;;) { s=bf.readLine(); if (s==null) break; StringTokenizer st = new StringTokenizer(s); if (st.hasMoreTokens()) { String word = st.nextToken(); addInConv(word,wordConv); } } bf.close(); } catch (IOException e) { e.printStackTrace(); } }
addInConv(mot,wordConv); newmot = wordConv.get(mot);
NamesConversion nc = new NamesConversion(); nc.buildPhoneConversion(MMFfile); nc.buildWordConversion(lexFile); System.out.println("converting phones in MMF to "+MMFfile+".conv"); nc.convertMMF(MMFfile); if (lexFile!=null) { System.out.println("converting phones and words in lexicon to "+lexFile+".conv"); nc.convertLexicon(lexFile); nc.convertLexicon(fillerFile); nc.convertWordGrammar(gramFile);
void convertMMF(String MMFfile) { try { BufferedReader bf = new BufferedReader(new FileReader(MMFfile)); PrintWriter pf = new PrintWriter(new FileWriter(MMFfile+".conv")); String s; for (;;) { s=bf.readLine(); if (s==null) break; int i=s.indexOf("~h"); if (i>=0) { i=s.indexOf('"'); int j = s.lastIndexOf('"'); String nom = s.substring(i+1,j); split3ph(nom); String newnom = conv3ph(); pf.println("~h \""+newnom+ '\"'); } else pf.println(s); } pf.close(); bf.close(); } catch (IOException e) { e.printStackTrace(); } }
void buildPhoneConversion(String MMFfile) { try { BufferedReader bf = new BufferedReader(new FileReader(MMFfile)); String s; for (;;) { s=bf.readLine(); if (s==null) break; int i=s.indexOf("~h"); if (i>=0) { i=s.indexOf('"'); int j = s.lastIndexOf('"'); String nom = s.substring(i+1,j); split3ph(nom); if (left!=null) addInConv(left,phoneConv); if (base!=null) addInConv(base,phoneConv); if (right!=null) addInConv(right,phoneConv); } } bf.close(); } catch (IOException e) { e.printStackTrace(); } } void buildWordConversion(String lexFile) {
void buildWordConversion(String lexFile) { try { BufferedReader bf = new BufferedReader(new FileReader(lexFile)); String s; for (;;) { s=bf.readLine(); if (s==null) break; StringTokenizer st = new StringTokenizer(s); if (st.hasMoreTokens()) { String word = st.nextToken(); addInConv(word,wordConv); } } bf.close(); } catch (IOException e) { e.printStackTrace(); } }
String conv3ph() { String rep; if (left!=null) { rep=conv1ph(left)+ '-'; } else rep=""; rep+=conv1ph(base); if (right!=null) { rep+= '+' +conv1ph(right); } if (rep.equals("null")) { System.err.println("detson error "+left+ ' ' +base+ ' ' +right); System.exit(1); } return rep; } String conv1ph(String p) {
addInConv(mot,wordConv); newmot = wordConv.get(mot);