Exemple #1
0
        public static void TestEdit()
        {
            string w1 = Console.ReadLine();
            string w2 = Console.ReadLine();

            double d = EditDistance.ComputeEditDistanceDP(w1, w2);

            Console.WriteLine(w1 + " , " + w2 + " : " + d);
        }
Exemple #2
0
 public static void PrintEditDistance(List <Tuple <double, string> > values, List <Tuple <double, string> > edList, string word)
 {
     pos = new Tuple <int, int>(Console.CursorLeft, Console.CursorTop);
     SetCursor(0, 2);
     ClearLine();
     Console.Write("Edit Distance: ");
     for (int i = 0; i < promptCount && i < values.Count; i++)
     {
         Console.Write(String.Format("{2}){0}: {1:0.00}  ", values[i].Item2, EditDistance.ComputeEditDistanceDP(values[i].Item2, word), (i + 1) % 10));
     }
     SetCursor(pos.Item1, pos.Item2);
 }
Exemple #3
0
        public static List <Tuple <double, string> > EvaluateLikelihood(Queue <string> predicate, string currentWord, Model m)
        {
            model = m;
            List <Tuple <double, string> > values = new List <Tuple <double, string> >();

            dictionary = model.GetDictionary();

            ed = EditDistance.ComputeEditDistances(dictionary, currentWord);
            SetUpDistributionVector(predicate);
            foreach (Tuple <double, string> t in ed)
            {
                double value = ComputeWeightedProbability(t.Item2);
                value /= (t.Item1 * edWeight);
                value *= scale;
                values.Add(new Tuple <double, string>(value, t.Item2));
            }
            values.Sort();
            values.Reverse();
            Writer.PrintPostWriteEvaluation(values);
            Writer.PrintProbabilityDistribution(values, distributions[0]);
            Writer.PrintEditDistance(values, ed, currentWord);
            return(values);
        }