Beispiel #1
0
 public string audit(post p)
 {
     int i = -1;
     double n = 0;
     for (int j = 0; j < vectors.Length; j++)
     {
         double max = 0;
         foreach (string k in p.analiz_vector.Keys)
         {
             if (vectors[j].values.ContainsKey(k))
                 max+= vectors[j].values[k];
         }
         if (max > n)
         {
             n = max;
             i = j;
         }
     }
     if (i > -1)
         return vectors[i].name;
     else
         return "Error";
 }
Beispiel #2
0
 public void add(post 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]);
             }
         }
     }
 }
Beispiel #3
0
        static void Main(string[] args)
        {
            post p1 = new post(@"posts\1t1.txt");
            post p2 = new post(@"posts\2t1.txt");
            post p3 = new post(@"posts\3t1.txt");
            vector v1 = new vector("наука");
            v1.add(p1);
            v1.add(p2);
            v1.add(p3);

            post p21 = new post(@"posts\1t2.txt");
            post p22 = new post(@"posts\2t2.txt");
            post p23 = new post(@"posts\3t2.txt");

            vector v2 = new vector("sport");
            v2.add(p21);
            v2.add(p22);
            v2.add(p23);

            analizator a = new analizator(new vector[] { v1, v2 });
            post t1 = new post(@"posts\t1.txt");
            post t2 = new post(@"posts\t2.txt");

            Console.WriteLine(a.audit(t1));
            Console.WriteLine(a.audit(t2));
        }