예제 #1
0
        static void Main(string[] args)
        {
            stattya s1 = new stattya(@"E:\Універ\Прога\KNN\It1.txt");
            stattya s2 = new stattya(@"E:\Універ\Прога\KNN\It2.txt");
            stattya s3 = new stattya(@"E:\Універ\Прога\KNN\It3.txt");
            vector v1 = new vector("IT");
            v1.add(s1);
            v1.add(s2);
            v1.add(s3);

            stattya ss1 = new stattya(@"E:\Універ\Прога\KNN\Sport1.txt");
            stattya ss2 = new stattya(@"E:\Універ\Прога\KNN\Sport2.txt");
            stattya ss3 = new stattya(@"E:\Універ\Прога\KNN\Sport3.txt");

            vector v2 = new vector("sport");
            v2.add(ss1);
            v2.add(ss2);
            v2.add(ss3);

            analizator a = new analizator(new vector[] { v1, v2 });
            stattya t1 = new stattya(@"E:\Універ\Прога\KNN\It4.txt");
            stattya t2 = new stattya(@"E:\Універ\Прога\KNN\Sport4.txt");

            Console.WriteLine(a.audit(t1));
            Console.WriteLine(a.audit(t2));
            Console.ReadKey();
        }
예제 #2
0
 public string audit(stattya p)
 {
     int i = -1;
     int n = 0;
     for (int j = 0; j < vectors.Length; j++)
     {
         int max = 0;
         foreach (string k in p.analiz_vector.Keys)
         {
             if (vectors[j].values.ContainsKey(k))
                 max++;
         }
         if (max > n)
         {
             n = max;
             i = j;
         }
     }
     if (i > -1)
         return vectors[i].name;
     else
         return "Error";
 }
예제 #3
0
 public void add(stattya p)
 {
     Dictionary<string, double> add_list = p.analiz_vector;
     if (values == null)
     {
         values = add_list;
     }
     else
     {
         foreach (string a in add_list.Keys)
         {
             if (values.ContainsKey(a))
             {
                 values[a] = (values[a] + add_list[a]) / 2;
             }
             else
             {
                 values.Add(a, add_list[a]);
             }
         }
     }
 }