private string SelectPostfix(Noun word, InflectionCase aCase, DecliantionNumber amount, string root, params string[] postfixes) { foreach (NounPostfixToken token in this.endings) { if (token.Declination == word.DeclinationType && token.Genre == word.Genre && token.DecliantionNumber == amount && token.InflectionCase == aCase) { if (token.Postfixes.Length > 1) { int indx = NounGrammar.GetPostFixIndex(word, amount, aCase); if (indx < token.Postfixes.Length) { return(token.Postfixes[indx]); } else { return(""); } } else { return(token.Postfixes[0]); } } } return(""); //postfixes[0]; }
public void LoadFromFile(string filePath) { this.nouns.Clear(); FileInfo fi = new FileInfo(filePath); TextReader tr = new StreamReader(fi.FullName, Encoding.Unicode, 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 } Noun noun = this._grammarSerializers.NounSerializer.Load(line); if (noun != null) { List <Noun> subList = null; if (this.sortedNouns.ContainsKey(noun.Genre)) { subList = this.sortedNouns[noun.Genre]; } else { subList = new List <Noun>(); this.sortedNouns.Add(noun.Genre, subList); } subList.Add(noun); this.nouns.Add(noun); } } } finally { tr.Close(); } }
public string MakeWord(Adjective word, Noun noun, InflectionCase aCase, DecliantionNumber amount, AdjectiveLevel level) { return(this.MakeWord(word, (noun.HasIrregularGenre) ? noun.IrregularGenre : noun.Genre, aCase, amount, level)); }
public string MakeWord(Noun word, InflectionCase aCase, DecliantionNumber amount) { if (aCase == InflectionCase._Unknown || amount == DecliantionNumber._Unknown) { return(null); } if ((amount == DecliantionNumber.Singular && !word.CanBeSingular) || (amount == DecliantionNumber.Plural && !word.CanBePlural)) { return(null); } if (word.IsConstant) { return(word.Root); } if (word.IsException) { string except = NounGrammar.GetForm(word, aCase, amount); if (except != null) { return(except); // else - calculate own... } } string prefix = ""; string postfix = ""; string root = ((aCase != InflectionCase.Nominative || amount != DecliantionNumber.Singular) && !string.IsNullOrEmpty(word.RootOther)) ? word.RootOther : word.Root; #region Switching postfix = this.SelectPostfix(word, aCase, amount, root); if (postfix == "*") { postfix = ""; } #if SW switch (word.Genre) { #region MasculineLife case GrammaticalGender.MasculineLife: { switch (aCase) { case InflectionCase.Nominative: // Mianownik { switch (amount) { case DecliantionNumber.Singular: { break; } case DecliantionNumber.Plural: { break; } } break; } case InflectionCase.Genitive: //Dopełniacz { switch (amount) { case DecliantionNumber.Singular: { break; } case DecliantionNumber.Plural: { break; } } break; } case InflectionCase.Dative: // Celownik { switch (amount) { case DecliantionNumber.Singular: { break; } case DecliantionNumber.Plural: { break; } } break; } case InflectionCase.Accusative: // Biernik { switch (amount) { case DecliantionNumber.Singular: { break; } case DecliantionNumber.Plural: { break; } } break; } case InflectionCase.Ablative: // Narzędnik { switch (amount) { case DecliantionNumber.Singular: { break; } case DecliantionNumber.Plural: { break; } } break; } case InflectionCase.Locative: // Miejscownik { switch (amount) { case DecliantionNumber.Singular: { break; } case DecliantionNumber.Plural: { break; } } break; } case InflectionCase.Vocative: //Wołacz { switch (amount) { case DecliantionNumber.Singular: { break; } case DecliantionNumber.Plural: { break; } } break; } } break; } #endregion #region MasculinePerson case GrammaticalGender.MasculinePerson: { switch (aCase) { case InflectionCase.Nominative: // Mianownik { switch (amount) { case DecliantionNumber.Singular: { break; } case DecliantionNumber.Plural: { break; } } break; } case InflectionCase.Genitive: //Dopełniacz { switch (amount) { case DecliantionNumber.Singular: { break; } case DecliantionNumber.Plural: { break; } } break; } case InflectionCase.Dative: // Celownik { switch (amount) { case DecliantionNumber.Singular: { break; } case DecliantionNumber.Plural: { break; } } break; } case InflectionCase.Accusative: // Biernik { switch (amount) { case DecliantionNumber.Singular: { break; } case DecliantionNumber.Plural: { break; } } break; } case InflectionCase.Ablative: // Narzędnik { switch (amount) { case DecliantionNumber.Singular: { break; } case DecliantionNumber.Plural: { break; } } break; } case InflectionCase.Locative: // Miejscownik { switch (amount) { case DecliantionNumber.Singular: { break; } case DecliantionNumber.Plural: { break; } } break; } case InflectionCase.Vocative: //Wołacz { switch (amount) { case DecliantionNumber.Singular: { break; } case DecliantionNumber.Plural: { break; } } break; } } break; } #endregion #region MasculineThing case GrammaticalGender.MasculineThing: { switch (aCase) { case InflectionCase.Nominative: // Mianownik { switch (amount) { case DecliantionNumber.Singular: { break; // Nothing } case DecliantionNumber.Plural: { root = Soften(word, root); postfix = "y"; break; } } break; } case InflectionCase.Genitive: //Dopełniacz { switch (amount) { case DecliantionNumber.Singular: { root = Soften(word, root); //postfix = SelectPostfix(word, root, "a", "u"); break; } case DecliantionNumber.Plural: { root = Soften(word, root); //postfix = SelectPostfix(word, root, "y", "ów"); break; } } break; } case InflectionCase.Dative: // Celownik { switch (amount) { case DecliantionNumber.Singular: { break; } case DecliantionNumber.Plural: { break; } } break; } case InflectionCase.Accusative: // Biernik { switch (amount) { case DecliantionNumber.Singular: { break; } case DecliantionNumber.Plural: { break; } } break; } case InflectionCase.Ablative: // Narzędnik { switch (amount) { case DecliantionNumber.Singular: { break; } case DecliantionNumber.Plural: { break; } } break; } case InflectionCase.Locative: // Miejscownik { switch (amount) { case DecliantionNumber.Singular: { break; } case DecliantionNumber.Plural: { break; } } break; } case InflectionCase.Vocative: //Wołacz { switch (amount) { case DecliantionNumber.Singular: { break; } case DecliantionNumber.Plural: { break; } } break; } } break; } #endregion #region Feminine case GrammaticalGender.Feminine: { switch (aCase) { case InflectionCase.Nominative: // Mianownik { switch (amount) { case DecliantionNumber.Singular: { break; } case DecliantionNumber.Plural: { break; } } break; } case InflectionCase.Genitive: //Dopełniacz { switch (amount) { case DecliantionNumber.Singular: { break; } case DecliantionNumber.Plural: { break; } } break; } case InflectionCase.Dative: // Celownik { switch (amount) { case DecliantionNumber.Singular: { break; } case DecliantionNumber.Plural: { break; } } break; } case InflectionCase.Accusative: // Biernik { switch (amount) { case DecliantionNumber.Singular: { break; } case DecliantionNumber.Plural: { break; } } break; } case InflectionCase.Ablative: // Narzędnik { switch (amount) { case DecliantionNumber.Singular: { break; } case DecliantionNumber.Plural: { break; } } break; } case InflectionCase.Locative: // Miejscownik { switch (amount) { case DecliantionNumber.Singular: { break; } case DecliantionNumber.Plural: { break; } } break; } case InflectionCase.Vocative: //Wołacz { switch (amount) { case DecliantionNumber.Singular: { break; } case DecliantionNumber.Plural: { break; } } break; } } break; } #endregion #region Neuter case GrammaticalGender.Neuter: { switch (aCase) { case InflectionCase.Nominative: // Mianownik { switch (amount) { case DecliantionNumber.Singular: { break; } case DecliantionNumber.Plural: { break; } } break; } case InflectionCase.Genitive: //Dopełniacz { switch (amount) { case DecliantionNumber.Singular: { break; } case DecliantionNumber.Plural: { break; } } break; } case InflectionCase.Dative: // Celownik { switch (amount) { case DecliantionNumber.Singular: { break; } case DecliantionNumber.Plural: { break; } } break; } case InflectionCase.Accusative: // Biernik { switch (amount) { case DecliantionNumber.Singular: { break; } case DecliantionNumber.Plural: { break; } } break; } case InflectionCase.Ablative: // Narzędnik { switch (amount) { case DecliantionNumber.Singular: { break; } case DecliantionNumber.Plural: { break; } } break; } case InflectionCase.Locative: // Miejscownik { switch (amount) { case DecliantionNumber.Singular: { break; } case DecliantionNumber.Plural: { break; } } break; } case InflectionCase.Vocative: //Wołacz { switch (amount) { case DecliantionNumber.Singular: { break; } case DecliantionNumber.Plural: { break; } } break; } } break; } #endregion } #endif #endregion return(string.Format("{0}{1}{2}", prefix, root, postfix)); }
private string Soften(Noun word, string root) { return(root); }