Exemple #1
0
 public static void _SCALE(List <Scale> _Scales, ref int i, ref string line)
 {
     try{
         string temp = "";
         for (; i < line.Length && line[i] != ']'; i++)
         {
             temp += line[i];
         }
         for (; i < line.Length && line[i] != '<'; i++)
         {
             temp += line[i];
         }
         temp = temp.Trim();
         int   k     = 0;
         Scale scale = new Scale(
             Additional_functions.Trim(temp, ref k, '[', ']').Replace('\n', ' ').Replace('\r', ' ').Replace(" ", ""),
             Additional_functions.Trim(temp, ref k, '(', ')'),
             Additional_functions.ClearLine(ref i, line)
             );
         _Scales.Add(scale);
     }
     catch {
         Stored_Exceptions.Add(new Exception("Error: _Scales exception, Scale number " + _Scales.Count + 1));
     }
 }
Exemple #2
0
 public void Calculation_measure_of_expression(List <Dictionary <string, double> > Dictionary_of_scales, List <Test> TESTS)
 {
     for (int number_group = 0; number_group < Groups.Count; number_group++)
     {
         for (int number_link = 0; number_link < Groups[number_group].Links.Count; number_link++)
         {
             double Sum = 0;
             for (int i = 0; i < Groups[number_group].Links[number_link].Test_name.Count; i++)
             {
                 int number_test = Additional_functions.Number_of_Contains(TESTS, Groups[number_group].Links[number_link].Test_name[i]);
                 if (number_test >= 0 && Dictionary_of_scales[number_test].TryGetValue(Groups[number_group].Links[number_link].Scale_name[i], out double point_on_scale))
                 {
                     Sum += Return_Measure_for_fuzzy_sets(
                         TESTS[number_test],
                         Groups[number_group].Links[number_link].Scale_name[i],
                         point_on_scale, Groups[number_group].Links[number_link].Function_number[i]
                         );
                 }
                 else
                 {
                     Stored_Exceptions.Add(new Exception("Error: cannot find name of scale"));
                 }
             }
             if (Stored_Exceptions.Empty)
             {
                 Groups[number_group].Links[number_link].Measure_of_expression = Sum / Groups[number_group].Links[number_link].Scale_name.Count;
             }
         }
     }
 }
Exemple #3
0
 public static List <double> _SUM_counting(List <Key> keys, Answers_to_Test Answers_to_the_test)
 {
     try
     {
         List <double> Key_value_all = new List <double>();
         for (int scale_number = 0; scale_number < keys.Count; scale_number++)
         {
             double Point = 0;
             for (int i = 0; i < keys[scale_number].Count; i++)
             {
                 for (int j = 0; j < Answers_to_the_test[(keys[scale_number][i].Question - 1)].Count; j++)
                 {
                     if (Answers_to_the_test[(keys[scale_number][i].Question - 1)][j] == (keys[scale_number][i].Answer - 1))
                     {
                         Point += keys[scale_number][i].Point;
                     }
                 }
             }
             Key_value_all.Add(Point);
         }
         return(Key_value_all);
     }
     catch {
         Stored_Exceptions.Add(new Exception("Error: internal format is not correct"));
         return(null);
     }
 }
Exemple #4
0
        public static void _LINK(List <Group> Groups, ref int i, ref string line)
        {
            string temp = Additional_functions.ClearLine(ref i, line);

            try
            {
                string[] links = temp.Split('&');
                int      k     = 0;
                Link     L     = new Link();
                foreach (var l in links)
                {
                    L.Add(
                        Additional_functions.Trim(l, ref k, '{', '}'),
                        Additional_functions.Trim(l, ref k, '{', '}'),
                        Convert.ToInt32(Additional_functions.Trim(l, ref k, '[', ']'))
                        );
                    k = 0;
                }
                Groups[Groups.Count - 1].Links.Add(L);
            }
            catch
            {
                Stored_Exceptions.Add(new Exception("Error: Link exception, in Group " + Groups.Count));
            }
        }
Exemple #5
0
        public static void _FUZZY_SETS(List <Fuzzy_sets> _Fuzzy_sets, ref int i, ref string line)
        {
            Fuzzy_sets F_s = new Fuzzy_sets
            {
                Name = (Additional_functions.Trim(line, ref i, '(', ')')).Trim()
            };
            string temp = Additional_functions.ClearLine(ref i, line).Replace('\n', ' ').Replace('\r', ' ').Replace(" ", "");

            try{
                string[] Functions = temp.Split(',');
                int      k         = 0;
                foreach (var f in Functions)
                {
                    F_s.Functions.Add(new Trapeze(
                                          Additional_functions.ToLine(Additional_functions.Trim(f, ref k, '[', ']'), Additional_functions.Trim(f, ref k, '[', ']')),
                                          Additional_functions.ToLine(Additional_functions.Trim(f, ref k, '[', ']'), Additional_functions.Trim(f, ref k, '[', ']'))
                                          ));
                    k = 0;
                }
                _Fuzzy_sets.Add(F_s);
            }
            catch {
                Stored_Exceptions.Add(new Exception("Error: _Fuzzy_sets exception, fuzzy sets number " + _Fuzzy_sets.Count + 1));
            }
        }
Exemple #6
0
        public bool Creat_Personal_characteristic(string FileName)
        {
            using (StreamReader sr = new StreamReader(Setting.characteristics_path + "\\" + FileName + ".txt", Encoding.GetEncoding(1251)))
            {
                string line = sr.ReadToEnd();
                string keyword;
                for (int i = 0; i < line.Length; i++)
                {
                    if (line[i] == '_') // выделение ключевого слова
                    {
                        keyword = "";
                        for (; i < line.Length && line[i] != ' '; i++)
                        {
                            keyword += line[i];
                        }
                        Enum.TryParse(keyword, out Descriptors Descriptor);
                        switch (Descriptor) // заполнение класса
                        {
                        case Descriptors._GROUP:
                        {
                            Descriptors_implementation._GROUP(Groups, ref i, ref line);
                            break;
                        }

                        case Descriptors._LINK:
                        {
                            Descriptors_implementation._LINK(Groups, ref i, ref line);
                            break;
                        }

                        default:
                            break;
                        }
                    }
                }
                if (!Stored_Exceptions.Empty)
                {
                    Stored_Exceptions.Show();
                    MessageBox.Show("The file could not be read:");
                    return(false);
                }
            }
            return(true);
        }
Exemple #7
0
        public static string ClearLine(ref int i, string line, char l = '<', char r = '>', bool Trim = true) // выделение строки из текста, отчистка строки от  тегов < > и пробелов в начале и в конце
        {
            for (; i < line.Length && line[i] != l; i++)
            {
                ;
            }
            i++;
            string Line = "";

            for (; i < line.Length && line[i] != r && line[i] != l; i++)
            {
                Line += line[i];
            }
            if (i == line.Length)
            {
                Stored_Exceptions.Add(new Exception("Error: can not allocate descriptor"));
            }
            return(Trim ? Line.Trim() : Line);
        }
Exemple #8
0
 double Return_Measure_for_fuzzy_sets(Test TEST, string Scale_name, double point_on_scale, int number_function)
 {
     try
     {
         for (int i = 0; i < TEST._Fuzzy_sets.Count; i++)
         {
             if (TEST._Fuzzy_sets[i].Name == Scale_name)
             {
                 return(Convert.ToSingle(TEST._Fuzzy_sets[i].Functions[number_function - 1].Measure_of_belonging(Convert.ToSingle(point_on_scale))));
             }
         }
         return(0);
     }
     catch
     {
         Stored_Exceptions.Add(new Exception("Error: number the function for fuzzy sets given with wrong"));
         return(0);
     }
 }
Exemple #9
0
        public static void _KEY(List <Key> _Keys, ref int i, ref string line)
        {
            string temp = Additional_functions.ClearLine(ref i, line);

            temp = temp.Replace('\n', ' ').Replace('\r', ' ').Replace(" ", "");
            try{
                Key      key  = new Key();
                string[] rows = temp.Split('+');
                foreach (var row in rows)
                {
                    int k = 0;
                    key.Add(new Element(
                                Convert.ToInt32(Additional_functions.Trim(row, ref k, '[', ']')),
                                Convert.ToInt32(Additional_functions.Trim(row, ref k, '(', ')')),
                                Convert.ToSingle(Additional_functions.Trim(row, ref k, '=', '*').Replace('.', ','))
                                ));
                }
                _Keys.Add(key);
            }
            catch {
                Stored_Exceptions.Add(new Exception("Error: _Keys exception, key number " + _Keys.Count + 1));
            }
        }
Exemple #10
0
 public static string _SCALE_counting(Scale _Scale, List <double> Key_value, Dictionary <string, double> newscale)
 {
     try{
         string expression = _Scale.If_scale;
         expression = Additional_functions.Replace_Point(expression, Key_value);
         expression = expression.Replace(',', '.');
         if (!newscale.Keys.Contains(_Scale.Name_scale)) // add new name scale
         {
             string tmp = Additional_functions.Split_for_value(expression);
             tmp = Additional_functions.Clean_for_compilation(tmp);
             double point = Convert.ToSingle(Additional_functions.Verification_of_conditions(Constants_for_the_compiler.Begin_C, tmp, Constants_for_the_compiler.End));
             newscale.Add(_Scale.Name_scale, point);
         }
         if (Convert.ToBoolean(Additional_functions.Verification_of_conditions(Constants_for_the_compiler.Begin_V, expression, Constants_for_the_compiler.End)))
         {
             return("(" + _Scale.Name_scale + ") " + "Баллов - " + Convert.ToString(newscale[_Scale.Name_scale]) + "\r\n" + _Scale.Manifestation);
         }
         return(null);
     }
     catch {
         Stored_Exceptions.Add(new Exception("Error: internal format is not correct"));
         return(null);
     }
 }
Exemple #11
0
        bool Upload_data_from_file(string FileName)
        {
            using (StreamReader sr = new StreamReader(FileName))
            {
                string line = sr.ReadToEnd();
                string keyword;
                for (int i = 0; i < line.Length; i++)
                {
                    if (line[i] == '_') // выделение ключевого слова
                    {
                        keyword = "";
                        for (; i < line.Length && line[i] != ' '; i++)
                        {
                            keyword += line[i];
                        }
                        Enum.TryParse(keyword, out Descriptors Descriptor);
                        switch (Descriptor) // заполнение класса Test
                        {
                        case Descriptors._HEADER:
                        {
                            Descriptors_implementation._GET_RESULT(ref i, line, out _HEADER);
                            break;
                        }

                        case Descriptors._TEST_RESULT:
                        {
                            Descriptors_implementation._GET_RESULT(ref i, line, out _TEST_RESULT);
                            break;
                        }

                        case Descriptors._AUTOMATIC_RESUME:
                        {
                            Descriptors_implementation._GET_RESULT(ref i, line, out _AUTOMATIC_RESUME);
                            break;
                        }

                        case Descriptors._LEVELS_OF_EXPRESSION:
                        {
                            Descriptors_implementation._GET_RESULT(ref i, line, out _LEVELS_OF_EXPRESSION);
                            break;
                        }

                        case Descriptors._ANSWERS_TO_TESTS:
                        {
                            Descriptors_implementation._GET_RESULT(ref i, line, out _ANSWERS_TO_TESTS);
                            break;
                        }

                        case Descriptors._TEST_SCALES:
                        {
                            Descriptors_implementation._GET_RESULT(ref i, line, out _TEST_SCALES);
                            break;
                        }

                        default:
                            break;
                        }
                    }
                }
                if (!Stored_Exceptions.Empty)
                {
                    Stored_Exceptions.Show();
                    MessageBox.Show("The file could not be read:");
                    return(false);
                }
            }
            return(true);
        }
Exemple #12
0
        public bool Creat_test(string FileName) // создание теста
        {
            using (StreamReader sr = new StreamReader($"{Setting.tests_path}\\{FileName}", Encoding.GetEncoding(1251)))
            {
                string line = sr.ReadToEnd();
                string keyword;
                for (int i = 0; i < line.Length; i++)
                {
                    if (line[i] == '_') // выделение ключевого слова
                    {
                        keyword = "";
                        for (; i < line.Length && line[i] != ' '; i++)
                        {
                            keyword += line[i];
                        }
                        Enum.TryParse(keyword, out Descriptors Descriptor);
                        switch (Descriptor) // заполнение класса Test
                        {
                        case Descriptors._ANSWER:
                        {
                            Descriptors_implementation._ANSWER(_Questions, ref i, ref line);
                            break;
                        }

                        case Descriptors._QUESTION:
                        {
                            Descriptors_implementation._QUESTION(_Questions, ref i, ref line);
                            break;
                        }

                        case Descriptors._SCALE:
                        {
                            Descriptors_implementation._SCALE(_Scales, ref i, ref line);
                            break;
                        }

                        case Descriptors._KEY:
                        {
                            Descriptors_implementation._KEY(_Keys, ref i, ref line);
                            break;
                        }

                        case Descriptors._FUZZY_SETS:
                        {
                            Descriptors_implementation._FUZZY_SETS(_Fuzzy_sets, ref i, ref line);
                            break;
                        }

                        case Descriptors._NAME:
                        {
                            Descriptors_implementation._NAME(_Header, ref i, ref line);
                            break;
                        }

                        case Descriptors._DESCRIPTION:
                        {
                            Descriptors_implementation._DESCRIPTION(_Header, ref i, ref line);
                            break;
                        }

                        case Descriptors._VERIFIER:
                        {
                            Descriptors_implementation._VERIFIER(_Header, ref i, ref line);
                            break;
                        }

                        default:
                            break;
                        }
                    }
                }
                if (!Stored_Exceptions.Empty)
                {
                    Stored_Exceptions.Show();
                    MessageBox.Show("The file could not be read:");
                    return(false);
                }
            }
            return(true);
        }