Exemple #1
0
        internal virtual WordNode addSuccessor(Pronunciation pronunciation, float num, Map map)
        {
            WordNode wordNode = (WordNode)this.getSuccessor(pronunciation);
            WordNode wordNode2;

            if (wordNode == null)
            {
                wordNode2 = (WordNode)map.get(pronunciation);
                if (wordNode2 == null)
                {
                    wordNode2 = new WordNode(pronunciation, num);
                    map.put(pronunciation, wordNode2);
                }
                this.putSuccessor(pronunciation, wordNode2);
            }
            else
            {
                if (wordNode.getUnigramProbability() < num)
                {
                    wordNode.setUnigramProbability(num);
                }
                wordNode2 = wordNode;
            }
            return(wordNode2);
        }
Exemple #2
0
 public HMMNode[] getHMMNodes(EndNode endNode)
 {
     HMMNode[] array = (HMMNode[])this.endNodeMap.get(endNode.getKey());
     if (array == null)
     {
         HashMap  hashMap     = new HashMap();
         Unit     baseUnit    = endNode.getBaseUnit();
         Unit     leftContext = endNode.getLeftContext();
         Iterator iterator    = this.entryPoints.iterator();
         while (iterator.hasNext())
         {
             Unit    unit    = (Unit)iterator.next();
             HMM     hmm     = this.hmmPool.getHMM(baseUnit, leftContext, unit, HMMPosition.__END);
             HMMNode hmmnode = (HMMNode)hashMap.get(hmm);
             if (hmmnode == null)
             {
                 hmmnode = new HMMNode(hmm, 0f);
                 hashMap.put(hmm, hmmnode);
             }
             hmmnode.addRC(unit);
             Node[] successors = endNode.getSuccessors();
             int    num        = successors.Length;
             for (int i = 0; i < num; i++)
             {
                 Node     node     = successors[i];
                 WordNode wordNode = (WordNode)node;
                 hmmnode.addSuccessor(wordNode);
             }
         }
         array = (HMMNode[])hashMap.values().toArray(new HMMNode[hashMap.size()]);
         this.endNodeMap.put(endNode.getKey(), array);
     }
     return(array);
 }
Exemple #3
0
 private void connectSingleUnitWords(Unit lc, Node node, HashMap hashMap)
 {
     if (!this.singleUnitWords.isEmpty())
     {
         Iterator iterator = HMMTree.access_200(this.this_0).iterator();
         while (iterator.hasNext())
         {
             Unit    unit = (Unit)iterator.next();
             HMM     hmm  = HMMTree.access_100(this.this_0).getHMM(this.baseUnit, lc, unit, HMMPosition.__SINGLE);
             HMMNode hmmnode;
             if ((hmmnode = (HMMNode)hashMap.get(hmm)) == null)
             {
                 hmmnode = (HMMNode)node.addSuccessor(hmm, this.getProbability());
                 hashMap.put(hmm, hmmnode);
             }
             else
             {
                 node.putSuccessor(hmm, hmmnode);
             }
             hmmnode.addRC(unit);
             this.nodeCount++;
             Iterator iterator2 = this.singleUnitWords.iterator();
             while (iterator2.hasNext())
             {
                 Pronunciation pronunciation = (Pronunciation)iterator2.next();
                 if (pronunciation.getWord() == HMMTree.access_300(this.this_0).getSentenceStartWord())
                 {
                     HMMTree.access_402(this.this_0, new InitialWordNode(pronunciation, hmmnode));
                 }
                 else
                 {
                     float    num      = HMMTree.access_500(this.this_0, pronunciation.getWord());
                     WordNode wordNode = hmmnode.addSuccessor(pronunciation, num, HMMTree.access_600(this.this_0));
                     if (pronunciation.getWord() == HMMTree.access_300(this.this_0).getSentenceEndWord())
                     {
                         HMMTree.access_702(this.this_0, wordNode);
                     }
                 }
                 this.nodeCount++;
             }
         }
     }
 }
Exemple #4
0
        private void addPronunciation(Pronunciation pronunciation, float num)
        {
            Unit[] units = pronunciation.getUnits();
            Unit   unit  = units[0];

            HMMTree.EntryPoint entryPoint = this.entryPointTable.getEntryPoint(unit);
            entryPoint.addProbability(num);
            if (units.Length > 1)
            {
                Node node  = entryPoint.getNode();
                Unit unit2 = unit;
                for (int i = 1; i < units.Length - 1; i++)
                {
                    unit = units[i];
                    Unit unit3 = units[i + 1];
                    HMM  hmm   = this.hmmPool.getHMM(unit, unit2, unit3, HMMPosition.__INTERNAL);
                    if (hmm == null)
                    {
                        this.logger.severe(new StringBuilder().append("Missing HMM for unit ").append(unit.getName()).append(" with lc=").append(unit2.getName()).append(" rc=").append(unit3.getName()).toString());
                    }
                    else
                    {
                        node = node.addSuccessor(hmm, num);
                    }
                    unit2 = unit;
                }
                unit = units[units.Length - 1];
                EndNode  endNode  = new EndNode(unit, unit2, num);
                EndNode  endNode2 = node.addSuccessor(endNode, num);
                WordNode wordNode = endNode2.addSuccessor(pronunciation, num, this.wordNodeMap);
                if (wordNode.getWord().isSentenceEndWord())
                {
                    this.sentenceEndWordNode = wordNode;
                }
            }
            else
            {
                entryPoint.addSingleUnitWord(pronunciation);
            }
        }
Exemple #5
0
 internal virtual void addSuccessor(WordNode wordNode)
 {
     this.putSuccessor(wordNode, wordNode);
 }
Exemple #6
0
 internal static WordNode access_702(HMMTree hmmtree, WordNode result)
 {
     hmmtree.sentenceEndWordNode = result;
     return(result);
 }