internal static void load(Lattice lattice, StringTokenizer stringTokenizer) { string text = stringTokenizer.nextToken(); string text2 = stringTokenizer.nextToken(); long num = Long.parseLong(stringTokenizer.nextToken()); long num2 = Long.parseLong(stringTokenizer.nextToken()); Word word = new Word(text2, new Pronunciation[0], String.instancehelper_startsWith(text2, "<") || String.instancehelper_startsWith(text2, "[")); lattice.addNode(text, word, num, num2); }
private static void createNode(string text, Lattice lattice, Dictionary dictionary) { string[] array = String.instancehelper_split(text, "\\s"); string id = String.instancehelper_substring(array[3], 1, String.instancehelper_length(array[3]) - 1); string text2 = String.instancehelper_substring(array[5], 1); string text3 = String.instancehelper_substring(array[6], 2, String.instancehelper_length(array[6]) - 2); string text4 = String.instancehelper_substring(text2, 0, String.instancehelper_indexOf(text2, 91)); text2 = String.instancehelper_substring(text2, String.instancehelper_indexOf(text2, 91) + 1); string text5 = String.instancehelper_substring(text2, 0, String.instancehelper_indexOf(text2, 44)); string text6 = String.instancehelper_substring(text2, String.instancehelper_indexOf(text2, 44) + 1); Node node = lattice.addNode(id, dictionary.getWord(text4), (long)Integer.parseInt(text5), (long)Integer.parseInt(text6)); node.setPosterior(Double.parseDouble(text3)); if (String.instancehelper_equals(text4, "<s>")) { lattice.setInitialNode(node); } else if (String.instancehelper_equals(text4, "</s>")) { lattice.setTerminalNode(node); } }
public static Lattice readSlf(InputStream stream) { Lattice lattice = new Lattice(); LineNumberReader lineNumberReader = new LineNumberReader(new InputStreamReader(stream)); int num = 0; int num2 = 0; int num3 = 0; int num4 = 1; double num5 = 9.5; string text; while ((text = lineNumberReader.readLine()) != null) { string text2 = text; object obj = "Node definitions"; CharSequence charSequence = CharSequence.Cast(obj); if (String.instancehelper_contains(text2, charSequence)) { num2 = 0; num = 1; } else { string text3 = text; obj = "Link definitions"; charSequence = CharSequence.Cast(obj); if (String.instancehelper_contains(text3, charSequence)) { num2 = 1; num = 0; } else if (!String.instancehelper_startsWith(text, "#")) { if (num != 0) { string[] array = String.instancehelper_split(text, "\\s+"); if (array.Length != 3 || !String.instancehelper_startsWith(array[0], "I=") || !String.instancehelper_startsWith(array[1], "t=") || !String.instancehelper_startsWith(array[2], "W=")) { lineNumberReader.close(); string text4 = new StringBuilder().append("Unknown node definition: ").append(text).toString(); throw new IOException(text4); } int num6 = Integer.parseInt(String.instancehelper_substring(array[0], 2)); long beginTime = ByteCodeHelper.d2l(Double.parseDouble(String.instancehelper_substring(array[1], 2)) * 1000.0); string text5 = String.instancehelper_substring(array[2], 2); int isFiller = 0; if (num6 == num3 || String.instancehelper_equals(text5, "!ENTER")) { text5 = "<s>"; isFiller = 1; } if (num6 == num4 || String.instancehelper_equals(text5, "!EXIT")) { text5 = "</s>"; isFiller = 1; } if (String.instancehelper_equals(text5, "!NULL")) { text5 = "<sil>"; isFiller = 1; } if (String.instancehelper_startsWith(text5, "[")) { isFiller = 1; } Word word = new Word(text5, new Pronunciation[0], isFiller != 0); Node node = lattice.addNode(Integer.toString(num6), word, beginTime, -1L); if (String.instancehelper_equals(text5, "<s>")) { lattice.setInitialNode(node); } if (String.instancehelper_equals(text5, "</s>")) { lattice.setTerminalNode(node); } } else if (num2 != 0) { string[] array = String.instancehelper_split(text, "\\s+"); if (array.Length != 5 || !String.instancehelper_startsWith(array[1], "S=") || !String.instancehelper_startsWith(array[2], "E=") || !String.instancehelper_startsWith(array[3], "a=") || !String.instancehelper_startsWith(array[4], "l=")) { lineNumberReader.close(); string text6 = new StringBuilder().append("Unknown edge definition: ").append(text).toString(); throw new IOException(text6); } string text7 = String.instancehelper_substring(array[1], 2); string text8 = String.instancehelper_substring(array[2], 2); double acousticScore = Double.parseDouble(String.instancehelper_substring(array[3], 2)); double lmScore = Double.parseDouble(String.instancehelper_substring(array[4], 2)) * num5; lattice.addEdge((Node)lattice.nodes.get(text7), (Node)lattice.nodes.get(text8), acousticScore, lmScore); } else { if (String.instancehelper_startsWith(text, "start=")) { string text9 = text; object obj2 = "start="; obj = ""; object obj3 = obj2; charSequence = CharSequence.Cast(obj3); CharSequence charSequence2 = charSequence; obj3 = obj; charSequence = CharSequence.Cast(obj3); num3 = Integer.parseInt(String.instancehelper_replace(text9, charSequence2, charSequence)); } if (String.instancehelper_startsWith(text, "end=")) { string text10 = text; object obj4 = "end="; object obj3 = ""; obj = obj4; charSequence = CharSequence.Cast(obj); CharSequence charSequence3 = charSequence; obj = obj3; charSequence = CharSequence.Cast(obj); num4 = Integer.parseInt(String.instancehelper_replace(text10, charSequence3, charSequence)); } if (String.instancehelper_startsWith(text, "lmscale=")) { string text11 = text; object obj5 = "lmscale="; obj = ""; object obj3 = obj5; charSequence = CharSequence.Cast(obj3); CharSequence charSequence4 = charSequence; obj3 = obj; charSequence = CharSequence.Cast(obj3); num5 = Double.parseDouble(String.instancehelper_replace(text11, charSequence4, charSequence)); } } } } } Iterator iterator = lattice.nodes.values().iterator(); while (iterator.hasNext()) { Node node2 = (Node)iterator.next(); Iterator iterator2 = node2.getLeavingEdges().iterator(); while (iterator2.hasNext()) { Edge edge = (Edge)iterator2.next(); if (node2.getEndTime() < 0L || node2.getEndTime() > edge.getToNode().getBeginTime()) { node2.setEndTime(Math.max(edge.getToNode().getBeginTime(), node2.getBeginTime())); } } } return(lattice); }