public void LoadPostfixes(string filePath) { this.endings.Clear(); FileInfo fi = new FileInfo(filePath); TextReader tr = new StreamReader(fi.FullName, Encoding.Default, true); string line = null; try { while ((line = tr.ReadLine()) != null) { #if DEBUG if (line.Trim().StartsWith("EOF")) { break; // for testing purposes } #else if (line.Trim().StartsWith("EOF")) { continue; // ignore } #endif if (line.Trim().StartsWith(";")) { continue; // entry is commented out } string[] fields = line.Split('|'); if (fields.Length != 2) { return; // Error } if (fields[0].Length != 5) { return; // error } string str = fields[0]; GrammaticalGender genre = EnumHelper.GetWordGenre(str[0]); InflectionCase aCase = EnumHelper.GetWordCase(str[1]); DecliantionNumber amount = EnumHelper.GetWordAmount(str[2]); string declinType = str.Substring(3, 2); string[] postfixes = fields[1].Split(' '); NounPostfixToken token = new NounPostfixToken(genre, aCase, amount, declinType, postfixes); this.endings.Add(token); } } finally { tr.Close(); } }
public void AddUpdatePostfix(NounPostfixToken token) { foreach (NounPostfixToken aToken in this.endings) { if (token.Declination == aToken.Declination && token.Genre == aToken.Genre && token.DecliantionNumber == aToken.DecliantionNumber && token.InflectionCase == aToken.InflectionCase) { this.endings.Remove(aToken); break; } } this.endings.Add(token); }
public void LoadPostfixes(string filePath) { endings.Clear(); FileInfo fi = new FileInfo(filePath); TextReader tr = new StreamReader(fi.FullName, Encoding.Default, true); string line = null; try { while ((line = tr.ReadLine()) != null) { #if DEBUG if (line.Trim().StartsWith("EOF")) break; // for testing purposes #else if (line.Trim().StartsWith("EOF")) continue; // ignore #endif if (line.Trim().StartsWith(";")) continue; // entry is commented out string[] fields = line.Split('|'); if (fields.Length != 2) return; // Error if (fields[0].Length != 5) return; // error string str = fields[0]; GrammaticalGender genre = EnumHelper.GetWordGenre(str[0]); InflectionCase aCase = EnumHelper.GetWordCase(str[1]); DecliantionNumber amount = EnumHelper.GetWordAmount(str[2]); string declinType = str.Substring(3, 2); string[] postfixes = fields[1].Split(' '); NounPostfixToken token = new NounPostfixToken(genre, aCase, amount, declinType, postfixes); endings.Add(token); } } finally { tr.Close(); } }
public void AddUpdatePostfix(NounPostfixToken token) { foreach (NounPostfixToken aToken in this.endings) { if (token.Declination == aToken.Declination && token.Genre == aToken.Genre && token.DecliantionNumber == aToken.DecliantionNumber && token.InflectionCase == aToken.InflectionCase) { endings.Remove(aToken); break; } } this.endings.Add(token); }