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(); }
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(); }
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(); }
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(); } }