Beispiel #1
0
        /// <summary>
        /// Создание словаря с падежами слов
        /// </summary>
        /// <param name="resource">Строка с падежами слов</param>
        /// <returns></returns>
        public static Dictionary <string, WordForms> CreateWordFormsCache(string resource)
        {
            Dictionary <string, WordForms> cashe = new Dictionary <string, WordForms>();

            try
            {
                using (StringReader reader = new StringReader(resource))
                {
                    string line;
                    char[] tab = { '\t' };
                    while ((line = reader.ReadLine()) != null)
                    {
                        if (line.StartsWith("*"))
                        {
                            continue;
                        }

                        string[] arr = line.Split(tab);

                        if (arr.Length == 0)
                        {
                            continue;
                        }

                        if (!cashe.ContainsKey(arr[0]))
                        {
                            cashe[arr[0]] = new WordForms(arr);
                        }
                    }
                }
            }
            catch
            {
            }

            return(cashe);
        }
 /// <summary>
 /// Конструктор
 /// </summary>
 static PositionsDecliner()
 {
     Cashe = WordForms.CreateWordFormsCache(Properties.Resources.positions_forms);
 }