Пример #1
0
 private GrammarNode selectRandomSuccessor(GrammarNode grammarNode)
 {
     GrammarArc[] successors = grammarNode.getSuccessors();
     if (successors.Length > 1)
     {
         double[] array = new double[successors.Length];
         double   num   = (double)0f;
         for (int i = 0; i < array.Length; i++)
         {
             array[i] = ((double)successors[0].getProbability() + 1E-10) / ((double)successors[i].getProbability() + 1E-10);
             num     += array[i];
         }
         for (int i = 0; i < array.Length; i++)
         {
             double[] array2 = array;
             int      num2   = i;
             double[] array3 = array2;
             array3[num2] /= num;
         }
         double num3 = this.randomizer.nextDouble();
         int    num4 = 0;
         int    num5 = 0;
         while (num3 > 1E-10)
         {
             num4  = num5;
             num3 -= array[num5];
             num5++;
         }
         return(successors[num4].getGrammarNode());
     }
     return(successors[0].getGrammarNode());
 }
Пример #2
0
 private GrammarNode getEndNode(GrammarNode grammarNode)
 {
     GrammarArc[] successors = grammarNode.getSuccessors();
     if (!FSTGrammar.assertionsDisabled && (successors == null || successors.Length <= 0))
     {
         throw new AssertionError();
     }
     return(successors[0].getGrammarNode());
 }
Пример #3
0
 public virtual void dumpStatistics()
 {
     if (this.logger.isLoggable(Level.INFO))
     {
         int num = 0;
         this.logger.info(new StringBuilder().append("Num nodes : ").append(this.getNumNodes()).toString());
         Iterator iterator = this.grammarNodes.iterator();
         while (iterator.hasNext())
         {
             GrammarNode grammarNode = (GrammarNode)iterator.next();
             num += grammarNode.getSuccessors().Length;
         }
         this.logger.info(new StringBuilder().append("Num arcs  : ").append(num).toString());
         this.logger.info(new StringBuilder().append("Avg arcs  : ").append((float)num / (float)this.getNumNodes()).toString());
     }
 }