public string Conjugate(string verb, PersonalPronounEnum personalPronoun) { var stem = verb.Remove(verb.Length - 2); switch (personalPronoun) { case PersonalPronounEnum.FirstPersonSingular: return(stem + "e"); case PersonalPronounEnum.FirstPersonSingularMasculine: return(stem + "e"); case PersonalPronounEnum.FirstPersonSingularFeminine: return(stem + "e"); case PersonalPronounEnum.SecondPersonSingular: return(stem + "es"); case PersonalPronounEnum.SecondPersonSingularMasculine: return(stem + "es"); case PersonalPronounEnum.SecondPersonSingularFeminine: return(stem + "es"); case PersonalPronounEnum.ThirdPersonSingularMasculine: return(stem + "e"); case PersonalPronounEnum.ThirdPersonSingularFeminine: return(stem + "e"); case PersonalPronounEnum.ThirdPersonSingularImpersonal: return(stem + "e"); case PersonalPronounEnum.FirstPersonPluralMasculine: return(stem + "ons"); case PersonalPronounEnum.FirstPersonPluralFeminine: return(stem + "ons"); case PersonalPronounEnum.SecondPersonPluralMasculine: return(stem + "ez"); case PersonalPronounEnum.SecondPersonPluralFeminine: return(stem + "ez"); case PersonalPronounEnum.ThirdPersonPluralMasculine: return(stem + "ent"); case PersonalPronounEnum.ThirdPersonPluralFeminine: return(stem + "ent"); case PersonalPronounEnum.FirstPersonPlural: return(stem + "ons"); case PersonalPronounEnum.SecondPersonPlural: return(stem + "ez"); } throw new System.Exception("Unknown conjugation: " + personalPronoun + " , " + verb); }
public string GetConjugatedForm(PersonalPronounEnum pronoun, string verb, TenseEnum tense) { foreach (var rule in rules) { if (rule.IsMatchingRule(verb, tense)) { return(rule.Conjugate(verb, pronoun)); } } throw new System.Exception("I do not know how to conjugate this yet. Please implement more rules."); }
static void Main(string[] args) { var french = new FrenchFactory(); var verbConjugator = french.GetVerbConjugator(); var personalPronounInterpreter = french.GetPersonalPronounInterpreter(); var pronounInput = ""; while (true) { Console.WriteLine(""); PersonalPronounEnum pronoun = PersonalPronounEnum.Unidentified; do { Console.Write("Enter personal pronoun:"); try { pronounInput = System.Console.ReadLine(); pronoun = personalPronounInterpreter.GetFromString(pronounInput); } catch (System.Exception ex) { Console.WriteLine(ex.Message); } }while (pronoun == PersonalPronounEnum.Unidentified); Console.WriteLine("You selected " + pronoun.ToString()); Console.Write("Enter verb:"); var verb = System.Console.ReadLine(); try { Console.WriteLine(""); Console.WriteLine(pronounInput + " " + verbConjugator.GetConjugatedForm(pronoun, verb, TenseEnum.Present)); Console.WriteLine(""); } catch (System.Exception ex) { Console.WriteLine(ex.Message); } } }
public VerbWord(PersonalPronounEnum pronoun, string questionWord, string answerWord, IPronounContext pronounContext) : base(questionWord, answerWord) { _context = pronounContext; PersonalPronoun = pronoun; }
public string GetQuestionPersonalPronoun(PersonalPronounEnum pronoun) { return(_questionPronounMap[pronoun]); }
public string GetAnswerPersonalPronoun(PersonalPronounEnum pronoun) { return(_answerPronounMap[pronoun]); }
private string conjugateVerb(PersonalPronounEnum personalPronoun) { var rule = new RegularVerbsEndingWithErPresentTenseVerbConjugationRule(); return(rule.Conjugate("parler", personalPronoun)); }
public bool AddLearnedVerb(PersonalPronounEnum personalPronoun, string questionWord, string answerWord) { return(_memorisableItems.TryAdd(new VerbWord(personalPronoun, questionWord, answerWord, GetLanguageContext()))); }