Пример #1
0
        protected internal override GrammarNode createGrammar()
        {
            GrammarNode grammarNode = null;
            int         num         = this.createNodes(this.path);

            num++;
            GrammarNode grammarNode2 = this.createGrammarNode(num, "<sil>");

            grammarNode2.setFinalNode(true);
            num = this.expandWordNodes(num);
            ExtendedStreamTokenizer extendedStreamTokenizer = new ExtendedStreamTokenizer(this.path, true);

            while (!extendedStreamTokenizer.isEOF())
            {
                extendedStreamTokenizer.skipwhite();
                string @string = extendedStreamTokenizer.getString();
                if (@string == null)
                {
                    break;
                }
                if (String.instancehelper_equals(@string, "I"))
                {
                    if (!FSTGrammar.assertionsDisabled && grammarNode != null)
                    {
                        throw new AssertionError();
                    }
                    int    @int = extendedStreamTokenizer.getInt("initial ID");
                    string text = new StringBuilder().append("G").append(@int).toString();
                    grammarNode = this.createGrammarNode(@int, "<sil>");
                    this.nodes.put(text, grammarNode);
                    if (this.addInitialSilenceNode)
                    {
                        num++;
                        GrammarNode grammarNode3 = this.createGrammarNode(num, "<sil>");
                        grammarNode.add(grammarNode3, 0f);
                        grammarNode3.add(grammarNode, 0f);
                    }
                }
                else if (String.instancehelper_equals(@string, "T"))
                {
                    int         @int         = extendedStreamTokenizer.getInt("this id");
                    int         int2         = extendedStreamTokenizer.getInt("next id");
                    GrammarNode grammarNode3 = this.get(@int);
                    GrammarNode grammarNode4 = this.get(int2);
                    if (this.hasEndNode(grammarNode3))
                    {
                        grammarNode3 = this.getEndNode(grammarNode3);
                    }
                    float  num2    = 0f;
                    string string2 = extendedStreamTokenizer.getString();
                    if (string2 == null || String.instancehelper_equals(string2, ","))
                    {
                        if (string2 != null && String.instancehelper_equals(string2, ","))
                        {
                            extendedStreamTokenizer.getString();
                            num2 = extendedStreamTokenizer.getFloat("probability");
                        }
                        if (this.hasEndNode(grammarNode4))
                        {
                            grammarNode4 = this.getEndNode(grammarNode4);
                        }
                    }
                    else
                    {
                        string string3 = extendedStreamTokenizer.getString();
                        num2 = extendedStreamTokenizer.getFloat("probability");
                        if (String.instancehelper_equals(string3, "<unknown>"))
                        {
                            continue;
                        }
                        if (!FSTGrammar.assertionsDisabled && !this.hasWord(grammarNode4))
                        {
                            throw new AssertionError();
                        }
                    }
                    grammarNode3.add(grammarNode4, this.convertProbability(num2));
                }
                else if (String.instancehelper_equals(@string, "F"))
                {
                    int         @int         = extendedStreamTokenizer.getInt("this id");
                    float       @float       = extendedStreamTokenizer.getFloat("probability");
                    GrammarNode grammarNode3 = this.get(@int);
                    GrammarNode grammarNode4 = grammarNode2;
                    if (this.hasEndNode(grammarNode3))
                    {
                        grammarNode3 = this.getEndNode(grammarNode3);
                    }
                    grammarNode3.add(grammarNode4, this.convertProbability(@float));
                }
            }
            extendedStreamTokenizer.close();
            if (!FSTGrammar.assertionsDisabled && grammarNode == null)
            {
                throw new AssertionError();
            }
            return(grammarNode);
        }