/// <summary>
 /// Checks which parser (factored, PCFG, or dependency) was used and
 /// returns the score of the best parse from this parser.
 /// </summary>
 /// <remarks>
 /// Checks which parser (factored, PCFG, or dependency) was used and
 /// returns the score of the best parse from this parser.
 /// If no parse could be obtained, it returns Double.NEGATIVE_INFINITY.
 /// </remarks>
 /// <returns>the score of the best parse, or Double.NEGATIVE_INFINITY</returns>
 public virtual double GetBestScore()
 {
     if (parseSkipped)
     {
         return(double.NegativeInfinity);
     }
     if (bparser != null && parseSucceeded)
     {
         return(bparser.GetBestScore());
     }
     else
     {
         if (pparser != null && pparser.HasParse() && fallbackToPCFG)
         {
             return(pparser.GetBestScore());
         }
         else
         {
             if (dparser != null && dparser.HasParse())
             {
                 return(dparser.GetBestScore());
             }
             else
             {
                 return(double.NegativeInfinity);
             }
         }
     }
 }
Esempio n. 2
0
            public virtual void RecordScore(IKBestViterbiParser parser, PrintWriter pw)
            {
                double score = parser.GetBestScore();

                totScore += score;
                n++;
                if (pw != null)
                {
                    pw.Print(str + " score: " + nf.Format(score));
                    if (runningAverages)
                    {
                        pw.Print(" average score: " + nf.Format(totScore / n));
                    }
                    pw.Println();
                }
            }