Exemplo n.º 1
0
            private bool needsEmptyVersion(ContextPair contextPair)
            {
                UnitContext leftContext = contextPair.getLeftContext();

                Unit[] units = leftContext.getUnits();
                return(units.Length > 0 && this.getRightContextSize(units[0]) < this.getRightContextSize());
            }
Exemplo n.º 2
0
        internal static ContextPair get(UnitContext unitContext, UnitContext unitContext2)
        {
            ContextPair contextPair  = new ContextPair(unitContext, unitContext2);
            ContextPair contextPair2 = (ContextPair)ContextPair.contextPairCache.cache(contextPair);

            return((contextPair2 != null) ? contextPair2 : contextPair);
        }
Exemplo n.º 3
0
            private void addExitPoint(ContextPair contextPair, SentenceHMMState sentenceHMMState)
            {
                object obj = (List)this.exitPoints.get(contextPair);

                if ((List)obj == null)
                {
                    obj = new ArrayList();
                    this.exitPoints.put(contextPair, (ArrayList)obj);
                }
                object obj2 = obj;
                List   list;

                if (obj2 != null)
                {
                    if ((list = (obj2 as List)) == null)
                    {
                        throw new IncompatibleClassChangeError();
                    }
                }
                else
                {
                    list = null;
                }
                list.add(sentenceHMMState);
            }
Exemplo n.º 4
0
            public virtual SentenceHMMState getEntryPoint()
            {
                ContextPair contextPair = ContextPair.get(UnitContext.SILENCE, UnitContext.SILENCE);
                List        list        = this.getEntryPoints(contextPair);

                return((list != null && !list.isEmpty()) ? ((SentenceHMMState)list.get(0)) : null);
            }
Exemplo n.º 5
0
 public override bool equals(object obj)
 {
     if (this == obj)
     {
         return(true);
     }
     if (obj is ContextPair)
     {
         ContextPair contextPair = (ContextPair)obj;
         return(this.left.equals(contextPair.left) && this.right.equals(contextPair.right));
     }
     return(false);
 }
Exemplo n.º 6
0
            public virtual void expand()
            {
                Iterator iterator = this.leftContexts.iterator();

                while (iterator.hasNext())
                {
                    UnitContext unitContext = (UnitContext)iterator.next();
                    Iterator    iterator2   = this.getStartingContexts().iterator();
                    while (iterator2.hasNext())
                    {
                        UnitContext unitContext2 = (UnitContext)iterator2.next();
                        ContextPair contextPair  = ContextPair.get(unitContext, unitContext2);
                        this.entryPoints.put(contextPair, new ArrayList());
                    }
                }
                if (this.node.isFinalNode())
                {
                    GrammarState grammarState = new GrammarState(this.node);
                    Iterator     iterator3    = this.entryPoints.values().iterator();
                    while (iterator3.hasNext())
                    {
                        List list = (List)iterator3.next();
                        list.add(grammarState);
                    }
                }
                else if (!this.node.isEmpty())
                {
                    iterator = this.leftContexts.iterator();
                    while (iterator.hasNext())
                    {
                        UnitContext unitContext = (UnitContext)iterator.next();
                        this.expandWord(unitContext);
                    }
                }
                else
                {
                    iterator = this.entryPoints.entrySet().iterator();
                    while (iterator.hasNext())
                    {
                        Map.Entry   entry        = (Map.Entry)iterator.next();
                        ContextPair contextPair2 = (ContextPair)entry.getKey();
                        List        list2        = (List)entry.getValue();
                        BranchState branchState  = new BranchState(contextPair2.getLeftContext().toString(), contextPair2.getRightContext().toString(), this.node.getID());
                        list2.add(branchState);
                        this.addExitPoint(contextPair2, branchState);
                    }
                }
                this.addEmptyEntryPoints();
            }
Exemplo n.º 7
0
            private void expandPronunciation(UnitContext unitContext, Pronunciation pronunciation, int which)
            {
                UnitContext        startingContext    = this.getStartingContext(pronunciation);
                string             name               = new StringBuilder().append("P(").append(pronunciation.getWord()).append('[').append(unitContext).append(',').append(startingContext).append("])-G").append(this.getNode().getID()).toString();
                PronunciationState pronunciationState = new PronunciationState(name, pronunciation, which);

                FlatLinguist.access_100(this.this_0, new StringBuilder().append("     Expanding ").append(pronunciationState.getPronunciation()).append(" for lc ").append(unitContext).toString());
                ContextPair contextPair = ContextPair.get(unitContext, startingContext);
                List        list        = (List)this.entryPoints.get(contextPair);

                if (list == null)
                {
                    string text = new StringBuilder().append("No EP list for context pair ").append(contextPair).toString();

                    throw new Error(text);
                }
                list.add(pronunciationState);
                Unit[] units = pronunciation.getUnits();
                int    num   = units.Length - this.getRightContextSize();

                if (num < 0)
                {
                    num = 0;
                }
                SentenceHMMState sentenceHMMState = pronunciationState;
                int num2 = 0;

                while (sentenceHMMState != null && num2 < num)
                {
                    sentenceHMMState = this.attachUnit(pronunciationState, sentenceHMMState, units, num2, unitContext, UnitContext.EMPTY);
                    num2++;
                }
                SentenceHMMState sentenceHMMState2 = sentenceHMMState;
                Iterator         iterator          = this.rightContexts.iterator();

                while (iterator.hasNext())
                {
                    UnitContext unitContext2 = (UnitContext)iterator.next();
                    sentenceHMMState = sentenceHMMState2;
                    int num3 = num;
                    while (sentenceHMMState != null && num3 < units.Length)
                    {
                        sentenceHMMState = this.attachUnit(pronunciationState, sentenceHMMState, units, num3, unitContext, unitContext2);
                        num3++;
                    }
                }
            }
Exemplo n.º 8
0
            private SentenceHMMState attachUnit(PronunciationState parent, SentenceHMMState sentenceHMMState, Unit[] array, int num, UnitContext unitContext, UnitContext unitContext2)
            {
                Unit[]            lc                = this.getLC(unitContext, array, num);
                Unit[]            rc                = this.getRC(array, num, unitContext2);
                UnitContext       unitContext3      = UnitContext.get(rc);
                LeftRightContext  context           = LeftRightContext.get(lc, rc);
                Unit              unit              = FlatLinguist.access_200(this.this_0).getUnit(array[num].getName(), array[num].isFiller(), context);
                ExtendedUnitState extendedUnitState = new ExtendedUnitState(parent, num, unit);
                float             logInsertionProbablity;

                if (extendedUnitState.getUnit().isSilence())
                {
                    logInsertionProbablity = FlatLinguist.access_300(this.this_0);
                }
                else if (extendedUnitState.getUnit().isFiller())
                {
                    logInsertionProbablity = FlatLinguist.access_400(this.this_0);
                }
                else if (extendedUnitState.getWhich() == 0)
                {
                    logInsertionProbablity = FlatLinguist.access_500(this.this_0);
                }
                else
                {
                    logInsertionProbablity = FlatLinguist.access_600(this.this_0);
                }
                SentenceHMMState existingState = this.getExistingState(extendedUnitState);

                if (existingState != null)
                {
                    this.attachState(sentenceHMMState, existingState, 0f, logInsertionProbablity);
                    return(null);
                }
                this.attachState(sentenceHMMState, extendedUnitState, 0f, logInsertionProbablity);
                this.addStateToCache(extendedUnitState);
                sentenceHMMState = this.expandUnit(extendedUnitState);
                if (extendedUnitState.isLast())
                {
                    UnitContext unitContext4 = this.generateNextLeftContext(unitContext, array[num]);
                    ContextPair contextPair  = ContextPair.get(unitContext4, unitContext3);
                    this.addExitPoint(contextPair, sentenceHMMState);
                }
                return(sentenceHMMState);
            }
Exemplo n.º 9
0
            private void addEmptyEntryPoints()
            {
                HashMap  hashMap  = new HashMap();
                Iterator iterator = this.entryPoints.entrySet().iterator();

                while (iterator.hasNext())
                {
                    Map.Entry   entry       = (Map.Entry)iterator.next();
                    ContextPair contextPair = (ContextPair)entry.getKey();
                    if (this.needsEmptyVersion(contextPair))
                    {
                        ContextPair contextPair2 = ContextPair.get(contextPair.getLeftContext(), UnitContext.EMPTY);
                        object      obj          = (List)hashMap.get(contextPair2);
                        if ((List)obj == null)
                        {
                            obj = new ArrayList();
                            hashMap.put(contextPair2, (ArrayList)obj);
                        }
                        object     obj2       = obj;
                        Collection collection = (Collection)entry.getValue();
                        List       list;
                        if (obj2 != null)
                        {
                            if ((list = (obj2 as List)) == null)
                            {
                                throw new IncompatibleClassChangeError();
                            }
                        }
                        else
                        {
                            list = null;
                        }
                        list.addAll(collection);
                    }
                }
                this.entryPoints.putAll(hashMap);
            }
Exemplo n.º 10
0
 private List getEntryPoints(ContextPair contextPair)
 {
     return((List)this.entryPoints.get(contextPair));
 }