コード例 #1
0
        public CyrNounCollection()
        {
            CyrData data = new CyrData();
            TextReader treader = data.GetData("noun-rules.gz");
            string line;
            string[] parts;

            line = treader.ReadLine();

            while (line != null)
            {
                parts = line.Split(' ');
                rules.Add(int.Parse(parts[0]), parts[1]);
                line = treader.ReadLine();
            }

            treader.Dispose();
            treader = data.GetData("nouns.gz");
            line = treader.ReadLine();

            while (line != null)
            {
                parts = line.Split(' ');

                if (!words.ContainsKey(parts[0]))
                {
                    words.Add(parts[0], parts[1]);
                }

                line = treader.ReadLine();
            }

            treader.Dispose();
        }
コード例 #2
0
        protected T GetSimilarDetails <T>(string Word, Dictionary <string, T> Collection, out string CollectionWord)
        {
            CyrData data = new CyrData();

            CollectionWord = data.GetSimilar(Word, Collection.Keys.ToList(), this.AdjectiveMinSameLetters);

            if (CollectionWord.IsNullOrEmpty())
            {
                return(default(T));
            }

            return(this.GetDetails(CollectionWord, Collection));
        }
コード例 #3
0
        protected List <string> GetSimilarDetails(string Word, out string CollectionWord)
        {
            CyrData data = new CyrData();

            CollectionWord = data.GetSimilar(Word, words.Keys.ToList());

            if (CollectionWord.IsNullOrEmpty())
            {
                return(null);
            }

            return(this.GetDetails(CollectionWord));
        }
コード例 #4
0
        public CyrAdjectiveCollection()
        {
            CyrData    data    = new CyrData();
            TextReader treader = data.GetData("adjective-rules.gz");
            string     line;

            string[] parts;

            line = treader.ReadLine();

            while (line != null)
            {
                parts = line.Split(' ');
                rules.Add(int.Parse(parts[0]), parts[1]);
                line = treader.ReadLine();
            }

            treader.Dispose();
            treader = data.GetData("adjectives.gz");
            line    = treader.ReadLine();

            while (line != null)
            {
                parts = line.Split(' ');

                if (!masculineWords.ContainsKey(parts[0]))
                {
                    masculineWords.Add(parts[0], parts[1]);
                }

                line = treader.ReadLine();
            }

            treader.Dispose();

            this.Fill();
        }
コード例 #5
0
        public CyrNounCollection()
        {
            CyrData    data    = new CyrData();
            TextReader treader = data.GetData("noun-rules.gz");
            string     line;

            string[] parts;

            line = treader.ReadLine();

            while (line != null)
            {
                parts = line.Split(' ');
                rules.Add(int.Parse(parts[0]), parts[1]);
                line = treader.ReadLine();
            }

            treader.Dispose();
            treader = data.GetData("nouns.gz");
            line    = treader.ReadLine();

            while (line != null)
            {
                parts = line.Split(' ');

                if (!words.ContainsKey(parts[0]))
                {
                    words.Add(parts[0], new List <string>());
                }

                words[parts[0]].Add(parts[1]);

                line = treader.ReadLine();
            }

            treader.Dispose();
        }
コード例 #6
0
ファイル: CyrNounCollection.cs プロジェクト: ne2poy/Cyriller
        public CyrNounCollection()
        {
            CyrData    data = new CyrData();
            TextReader treader;
            string     line;
            bool       rulesBlock = true;

            treader = data.GetData(NounsResourceName);

            List <string>[] singularWordCandidates = new List <string>[] { new List <string>(), new List <string>(), new List <string>(), new List <string>(), new List <string>(), new List <string>() };
            List <string>[] pluralWordCandidates   = new List <string>[] { new List <string>(), new List <string>(), new List <string>(), new List <string>(), new List <string>(), new List <string>() };

            while (true)
            {
                line = treader.ReadLine();

                if (line == null)
                {
                    break;
                }
                else if (rulesBlock && line == EndOfTheRulesBlock)
                {
                    rulesBlock = false;
                    continue;
                }
                else if (this.IsSkipLine(line))
                {
                    continue;
                }

                if (rulesBlock)
                {
                    string[]  parts = line.Split(',', '|');
                    CyrRule[] rule  = new CyrRule[parts.Length];

                    for (int i = 0; i < parts.Length; i++)
                    {
                        rule[i] = new CyrRule(parts[i]);
                    }

                    this.rules.Add(rule);
                }
                else
                {
                    this.AddWordToTheCollection(line, singularWordCandidates, pluralWordCandidates);
                }
            }

            treader.Dispose();

            {
                IEnumerable <string> candidates = new string[0];

                foreach (List <string> candidate in singularWordCandidates)
                {
                    candidates = candidates.Concat(candidate);
                }

                foreach (List <string> candidate in pluralWordCandidates)
                {
                    candidates = candidates.Concat(candidate);
                }

                this.wordCandidates = candidates.Distinct().ToList();
            }
        }
コード例 #7
0
        protected string GetSimilarDetails(string Word, out string CollectionWord)
        {
            CyrData data = new CyrData();

            CollectionWord = data.GetSimilar(Word, words.Keys.ToList());

            if (CollectionWord.IsNullOrEmpty())
            {
                return null;
            }

            return this.GetDetails(CollectionWord);
        }