Пример #1
0
        private static List getNextGrammarNodesWithWords(GrammarNode grammarNode)
        {
            ArrayList arrayList = new ArrayList();

            GrammarArc[] successors = grammarNode.getSuccessors();
            int          num        = successors.Length;

            for (int i = 0; i < num; i++)
            {
                GrammarArc  grammarArc   = successors[i];
                GrammarNode grammarNode2 = grammarArc.getGrammarNode();
                if (grammarNode2.getAlternatives().Length == 0)
                {
                    if (grammarNode2.isFinalNode())
                    {
                        arrayList.add(grammarNode2);
                    }
                    else
                    {
                        arrayList.addAll(GrammarPoint.getNextGrammarNodesWithWords(grammarNode2));
                    }
                }
                else
                {
                    arrayList.add(grammarNode2);
                }
            }
            return(arrayList);
        }
Пример #2
0
        private List getNextGrammarPoints(bool flag)
        {
            ArrayList arrayList = new ArrayList();

            if (this.alternativeIndex == -1 && this.node.getAlternatives().Length > 0)
            {
                for (int i = 0; i < this.node.getAlternatives().Length; i++)
                {
                    GrammarPoint grammarPoint = new GrammarPoint(this.node, i, 0, 0, 0);
                    arrayList.add(grammarPoint);
                }
            }
            else if (this.node.getAlternatives().Length == 0)
            {
                GrammarPoint.addNextGrammarPointsWithWords(this.node, arrayList);
            }
            else
            {
                GrammarPoint grammarPoint2;
                if (flag)
                {
                    grammarPoint2 = this;
                }
                else
                {
                    grammarPoint2 = new GrammarPoint(this.node, this.alternativeIndex, this.wordIndex, this.pronunciationIndex, this.unitIndex + 1);
                }
                Pronunciation[] pronunciations = this.node.getAlternatives()[this.alternativeIndex][this.wordIndex].getPronunciations();
                int             num            = pronunciations[this.pronunciationIndex].getUnits().Length;
                if (grammarPoint2.unitIndex < num)
                {
                    arrayList.add(grammarPoint2);
                }
                else
                {
                    grammarPoint2.unitIndex = 0;
                    Word[]       array         = grammarPoint2.node.getAlternatives()[this.alternativeIndex];
                    GrammarPoint grammarPoint3 = grammarPoint2;
                    int          num2          = grammarPoint3.wordIndex + 1;
                    GrammarPoint grammarPoint4 = grammarPoint3;
                    int          num3          = num2;
                    grammarPoint4.wordIndex = num2;
                    if (num3 < array.Length)
                    {
                        Word word = array[grammarPoint2.wordIndex];
                        for (int j = 0; j < word.getPronunciations().Length; j++)
                        {
                            GrammarPoint grammarPoint5 = new GrammarPoint(grammarPoint2.node, grammarPoint2.alternativeIndex, grammarPoint2.wordIndex, j, 0);
                            arrayList.add(grammarPoint5);
                        }
                    }
                    else if (!GrammarPoint.bounded)
                    {
                        GrammarPoint.addNextGrammarPointsWithWords(grammarPoint2.node, arrayList);
                    }
                }
            }
            return(arrayList);
        }
Пример #3
0
        private static void addNextGrammarPointsWithWords(GrammarNode grammarNode, List list)
        {
            Iterator iterator = GrammarPoint.getNextGrammarNodesWithWords(grammarNode).iterator();

            while (iterator.hasNext())
            {
                GrammarNode grammarNode2 = (GrammarNode)iterator.next();
                for (int i = 0; i < grammarNode2.getAlternatives().Length; i++)
                {
                    GrammarPoint grammarPoint = new GrammarPoint(grammarNode2, i, 0, 0, 0);
                    list.add(grammarPoint);
                }
            }
        }
Пример #4
0
        public virtual List getRightContexts(int size, bool startWithCurrent, int maxContexts)
        {
            ArrayList arrayList         = new ArrayList();
            List      nextGrammarPoints = this.getNextGrammarPoints(startWithCurrent);

            if (nextGrammarPoints.isEmpty())
            {
                Unit[] emptyContext = Unit.getEmptyContext(size);
                this.addContext(arrayList, emptyContext);
            }
            else
            {
                Iterator iterator = nextGrammarPoints.iterator();
                while (iterator.hasNext())
                {
                    GrammarPoint grammarPoint = (GrammarPoint)iterator.next();
                    if (size == 1)
                    {
                        Unit[] array = new Unit[size];
                        array[0] = grammarPoint.getUnitOrFill();
                        this.addContext(arrayList, array);
                    }
                    else
                    {
                        List     rightContexts = grammarPoint.getRightContexts(size - 1, false, maxContexts - arrayList.size());
                        Iterator iterator2     = rightContexts.iterator();
                        while (iterator2.hasNext())
                        {
                            Unit[] array2        = (Unit[])iterator2.next();
                            Unit[] emptyContext2 = Unit.getEmptyContext(array2.Length + 1);
                            emptyContext2[0] = grammarPoint.getUnitOrFill();
                            ByteCodeHelper.arraycopy(array2, 0, emptyContext2, 1, array2.Length);
                            this.addContext(arrayList, emptyContext2);
                        }
                    }
                    if (arrayList.size() >= maxContexts)
                    {
                        break;
                    }
                }
            }
            return(arrayList);
        }