// сравнение
        private List <string[]> Sravn(string[][] data)
        {
            List <string[]> rezlist = new List <string[]>();

            foreach (string[] str in data)
            {
                // количество слов в строке
                if (str.Count() != 2)
                {
                    continue;
                }
                else
                {
                    string[] mass;

                    SimMetricsMetricUtilities.Levenstein ex_l = new SimMetricsMetricUtilities.Levenstein();

                    Stopwatch t = new Stopwatch();
                    t.Start();
                    double rj1 = Math.Round(Jaro.Func(str[0], str[1]), 2);
                    string tj1 = Math.Round(t.Elapsed.TotalMilliseconds, 2).ToString();

                    t = new Stopwatch();
                    t.Start();
                    double rj2 = Math.Round(ExJaro.distance(str[0], str[1]), 2);
                    string tj2 = Math.Round(t.Elapsed.TotalMilliseconds, 2).ToString();

                    // -----

                    t = new Stopwatch();
                    t.Start();
                    double rjv1 = Math.Round(JaroVincler.Func(str[0], str[1]), 2);
                    string tjv1 = Math.Round(t.Elapsed.TotalMilliseconds, 2).ToString();

                    t = new Stopwatch();
                    t.Start();
                    double rjv2 = Math.Round(ExJaroWincler.distance(str[0], str[1]), 2);
                    string tjv2 = Math.Round(t.Elapsed.TotalMilliseconds, 2).ToString();

                    // ----

                    t = new Stopwatch();
                    t.Start();
                    double rl1 = Math.Round(Levenstein.Func(str[0], str[1]), 2);
                    string tl1 = Math.Round(t.Elapsed.TotalMilliseconds, 2).ToString();

                    t = new Stopwatch();
                    t.Start();
                    double rl2 = Math.Round(ex_l.GetSimilarity(str[0], str[1]), 2);
                    string tl2 = Math.Round(t.Elapsed.TotalMilliseconds, 2).ToString();

                    rezlist.Add(new string[14] {
                        rj1.ToString(), tj1, rj2.ToString(), tj2,
                        rjv1.ToString(), tjv1, rjv2.ToString(), tjv2,
                        rl1.ToString(), tl1, rl2.ToString(), tl2, str[0], str[1]
                    });
                }
            }

            return(rezlist);
        }
Beispiel #2
0
 private void JaroVincler_button_Click(object sender, EventArgs e)
 {
     JaroVinclerRez.Text = JaroVincler.Func(JaroVinclerText1.Text, textBJaroVinclerText2.Text).ToString();
 }
Beispiel #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            Existing_Method ex_m = new Existing_Method();
            Jaro            m1;
            JaroVincler     m2;
            Levenstein      m3;

            Stopwatch t = new Stopwatch();

            double[] rez_mas = new double[20];

            if (System.IO.File.Exists("data.txt"))
            {
                string[] mass = System.IO.File.ReadAllLines("data.txt");
                System.IO.File.WriteAllText("ex_m.txt", "");

                // Существующий тест
                t.Start();
                foreach (string s in mass)
                {
                    string[] str = s.Split(' ');
                    System.IO.File.AppendAllText("ex_m.txt", ex_m.IndistinctMatching(4, str[0], str[1]).ToString() + Environment.NewLine);
                }
                t.Stop();
                System.IO.File.AppendAllText("ex_m.txt", t.Elapsed.ToString());


                System.IO.File.WriteAllText("m1.txt", "");

                // Метод 1
                t = new Stopwatch();
                t.Start();
                foreach (string s in mass)
                {
                    string[] str = s.Split(' ');
                    m1 = new Jaro(str[0], str[1]);
                    System.IO.File.AppendAllText("m1.txt", (m1.Func() * 100).ToString() + Environment.NewLine);
                }
                t.Stop();
                System.IO.File.AppendAllText("m1.txt", t.Elapsed.ToString());


                System.IO.File.WriteAllText("m2.txt", "");

                // Метод 2
                t = new Stopwatch();
                t.Start();
                foreach (string s in mass)
                {
                    string[] str = s.Split(' ');
                    m2 = new JaroVincler(str[0], str[1]);
                    if (m2.Func())
                    {
                        System.IO.File.AppendAllText("m2.txt", "100" + Environment.NewLine);
                    }
                    else
                    {
                        System.IO.File.AppendAllText("m2.txt", "0" + Environment.NewLine);
                    }
                }
                t.Stop();
                System.IO.File.AppendAllText("m2.txt", t.Elapsed.ToString());

                // Метод 3
                System.IO.File.WriteAllText("m3.txt", "");

                t = new Stopwatch();
                t.Start();
                foreach (string s in mass)
                {
                    string[] str = s.Split(' ');
                    m3 = new Levenstein(str[0], str[1]);
                    System.IO.File.AppendAllText("m3.txt", (100 - m3.Func() * 100).ToString() + Environment.NewLine);
                }
                t.Stop();
                System.IO.File.AppendAllText("m3.txt", t.Elapsed.ToString());

                MessageBox.Show("Выполнено");
            }
        }