public void SuruSpecial(string conjugatedWord, CForm form, Politeness politeness = Politeness.Plain, Polarity polarity = Polarity.Affirmative) { var word = "愛する"; var wordClass = EdictType.vs_s; Assert.AreEqual(conjugatedWord, JpConj.Conjugate(word, wordClass, form, politeness, polarity)); }
public VerbInfo(string verb, CForm form, Polarity polarity = Polarity.Affirmative, Politeness politeness = Politeness.Plain) { Verb = verb ?? throw new ArgumentNullException(nameof(verb)); Form = form; this.polarity = polarity; this.politeness = politeness; }
public void IrregularNu(string conjugatedWord, CForm form, Politeness politeness = Politeness.Plain, Polarity polarity = Polarity.Affirmative) { var word = "死ぬ"; var wordClass = EdictType.vn; Assert.AreEqual(conjugatedWord, JpConj.Conjugate(word, wordClass, form, politeness, polarity)); }
public void IchidanKureru(string conjugatedWord, CForm form, Politeness politeness = Politeness.Plain, Polarity polarity = Polarity.Affirmative) { var word = "くれる"; var wordClass = EdictType.v1_s; Assert.AreEqual(conjugatedWord, JpConj.Conjugate(word, wordClass, form, politeness, polarity)); }
public void GodanIkuYuku(string conjugatedWord, CForm form, Politeness politeness = Politeness.Plain, Polarity polarity = Polarity.Affirmative) { var word = "合点がいく"; // also 冴え行く var wordClass = EdictType.v5k_s; Assert.AreEqual(conjugatedWord, JpConj.Conjugate(word, wordClass, form, politeness, polarity)); }
public void GodanAru(string conjugatedWord, CForm form, Politeness politeness = Politeness.Plain, Polarity polarity = Polarity.Affirmative) { var word = "いらっしゃる"; var wordClass = EdictType.v5aru; Assert.AreEqual(conjugatedWord, JpConj.Conjugate(word, wordClass, form, politeness, polarity)); }
/// <summary> /// Returns a Politeness addressable by a Host. /// </summary> /// <param name = "host">The Host governed by the Politeness.</param> /// <returns> /// The Politeness governing the AbsoluteUri. /// </returns> public Politeness GetPoliteness(string host) { Politeness politeness = null; Politenesses.TryGetValue(host, out politeness); return(politeness); }
/// <summary> /// Adds a Politeness to the Cache with the sliding expiration specified by TimeSpan.FromDays(1). /// </summary> /// <param name = "politeness">The Politeness to be added.</param> public void AddPoliteness(Politeness politeness) { try { lock (_politenessesLock) { if (!Politenesses.ContainsKey(politeness.Host)) { Politenesses.Add(politeness.Host, politeness); Counters.GetInstance().PolitenessAdded(); } } } catch (Exception) { throw; } }
public static string Conjugate(string verb, EdictType type, CForm form, Politeness polite, Polarity affirmative) { if (verb.Length < 2) { return(verb); } string radical = verb; string end = Utils.Right(verb, 1); radical = Utils.Chop(radical, 1); string bar = "|"; switch (form) { case CForm.TeForm: if (affirmative != 0) { return(VerbStem.tForm(radical, type) + tEnd(end, true)); } if (type == EdictType.v5r_i) { var aru = Utils.Chop(radical, 1); return(aru + "||なくて"); } return(VerbStem.aForm(radical, type) + "|なくて"); case CForm.Present: if (polite != 0) { if (affirmative != 0) { return(VerbStem.iForm(radical, type) + "|ます"); } return(VerbStem.iForm(radical, type) + "|ません"); } //plain if (affirmative != 0) { return(VerbStem.uForm(radical, type) + "|"); } if (type == EdictType.v5r_i) { var aru = Utils.Chop(radical, 1); return(aru + "||ない"); } return(VerbStem.aForm(radical, type) + "|ない"); case CForm.Past: if (polite != 0) { if (affirmative != 0) { return(VerbStem.iForm(radical, type) + "|ました"); } return(VerbStem.iForm(radical, type) + "|ませんでした"); } //plain if (affirmative != 0) { return(VerbStem.tForm(radical, type) + tEnd(end, false)); } return(VerbStem.aForm(radical, type) + "|なかった"); case CForm.Provision: if (polite != 0) { if (affirmative != 0) { return(VerbStem.iForm(radical, type) + "|ますれば"); } return(VerbStem.iForm(radical, type) + "|ませんならば"); } //plain if (affirmative != 0) { return(VerbStem.eForm(radical, type) + "|ば"); } return(VerbStem.aForm(radical, type) + "|なければ"); case CForm.Condition: if (polite != 0) { if (affirmative != 0) { return(VerbStem.iForm(radical, type) + "|ましたら"); } return(VerbStem.iForm(radical, type) + "|ませんでしたら"); } //plain if (affirmative != 0) { return(VerbStem.tForm(radical, type) + tEnd(end, false) + "ら"); } return(VerbStem.aForm(radical, type) + "|なかったら"); case CForm.Imperative: if (polite != 0) { if (affirmative != 0) { return(VerbStem.tForm(radical, type) + tEnd(end, true) + "下さい"); } return(VerbStem.aForm(radical, type) + "|ないで下さい"); } //plain if (affirmative != 0) { return(VerbStem.eImpForm(radical, type) + "|"); } return(VerbStem.uForm(radical, type) + "|な"); case CForm.Volitional: if (polite != 0) { if (affirmative != 0) { return(VerbStem.iForm(radical, type) + "|ましょう"); } return(VerbStem.uForm(radical, type) + "|のをやめましょう"); } //plain if (affirmative != 0) { if (type == EdictType.v5r_i) { return("|" + radical + "|ろう"); } if (!EdictTypeUtils.IsGodan(type) && type != EdictType.vn) { return(VerbStem.oForm(radical, type) + "|よう"); } return(VerbStem.oForm(radical, type) + "|う"); } return(VerbStem.uForm(radical, type) + "|のをやめよう"); case CForm.PresentContinuous: if (polite != 0) { if (affirmative != 0) { return(VerbStem.tForm(radical, type) + tEnd(end, true) + "います"); } return(VerbStem.tForm(radical, type) + tEnd(end, true) + "いません"); } //plain if (affirmative != 0) { return(VerbStem.tForm(radical, type) + tEnd(end, true) + "いる"); } return(VerbStem.tForm(radical, type) + tEnd(end, true) + "いない"); case CForm.PastContinuous: if (polite != 0) { if (affirmative != 0) { return(VerbStem.tForm(radical, type) + tEnd(end, true) + "いました"); } return(VerbStem.tForm(radical, type) + tEnd(end, true) + "いませんでした"); } //plain if (affirmative != 0) { return(VerbStem.tForm(radical, type) + tEnd(end, true) + "いた"); } return(VerbStem.tForm(radical, type) + tEnd(end, true) + "いなかった"); case CForm.Potential: if (EdictTypeUtils.IsIchidan(type)) { radical += "||られ"; // radical + られ type = EdictType.v0; //to prevent changing the radical when using eForm bar = ""; } else if (type == EdictType.vs_s) { } else if (EdictTypeUtils.IsSuru(type)) { //suru verbs numbers are 27 26 25 24 if (type != EdictType.vs_c) // suru verb number 25 ends with su, no need to chop it { radical = Utils.Chop(radical, 1); } radical += "||でき"; type = EdictType.v0; //to prevent changing the radical when using eForm bar = ""; } else if (type == EdictType.vk) { if (radical.EndsWith("く")) { radical = Utils.Chop(radical, 1) + "こ"; } radical += "||られ"; type = EdictType.v0; //to prevent changing the radical when using eForm bar = ""; } if (polite != 0) { if (affirmative != 0) { return(VerbStem.eForm(radical, type) + bar + "ます"); } return(VerbStem.eForm(radical, type) + bar + "ません"); } //plain if (affirmative != 0) { return(VerbStem.eForm(radical, type) + bar + "る"); } return(VerbStem.eForm(radical, type) + bar + "ない"); case CForm.Passive: if (EdictTypeUtils.IsIchidan(type)) { radical += "||ら"; type = EdictType.v0; //to prevent changing the radical when using eForm bar = ""; } else if (EdictTypeUtils.IsSuru(type)) { //suru verbs numbers are 27 26 25 24 if (type != EdictType.vs_c) // suru verb number 27 ends with su, no need to chop it { radical = Utils.Chop(radical, 1); } radical += "||さ"; type = EdictType.v0; //to prevent changing the radical when using eForm bar = ""; } else if (type == EdictType.vk || type == EdictType.vz) { bar = "|ら"; } if (polite != 0) { if (affirmative != 0) { return(VerbStem.aForm(radical, type) + bar + "れます"); } return(VerbStem.aForm(radical, type) + bar + "れません"); } //plain if (affirmative != 0) { return(VerbStem.aForm(radical, type) + bar + "れる"); } return(VerbStem.aForm(radical, type) + bar + "れない"); case CForm.Causative: if (EdictTypeUtils.IsIchidan(type)) { radical += "||さ"; type = EdictType.v0; //to prevent changing the radical when using eForm bar = ""; } else if (EdictTypeUtils.IsSuru(type)) { //suru verbs numbers are 27 26 25 24 if (type != EdictType.vs_c) // suru verb number 27 ends with su, no need to chop it { radical = Utils.Chop(radical, 1); } radical += "||さ"; type = EdictType.v0; //to prevent changing the radical when using eForm bar = ""; } else if (type == EdictType.vk || type == EdictType.vz) { bar = "|さ"; } if (polite != 0) { if (affirmative != 0) { return(VerbStem.aForm(radical, type) + bar + "せます"); } return(VerbStem.aForm(radical, type) + bar + "せません"); } //plain if (affirmative != 0) { return(VerbStem.aForm(radical, type) + bar + "せる"); } return(VerbStem.aForm(radical, type) + bar + "せない"); case CForm.CausativePassive: if (EdictTypeUtils.IsIchidan(type)) { radical += "||さ"; type = EdictType.v0; //to prevent changing the radical when using eForm bar = ""; } else if (EdictTypeUtils.IsSuru(type)) { //suru verbs numbers are 27 26 25 24 if (type != EdictType.vs_c) // suru verb number 27 ends with su, no need to chop it { radical = Utils.Chop(radical, 1); } radical += "||さ"; type = EdictType.v0; //to prevent changing the radical when using eForm bar = ""; } else if (type == EdictType.vk || type == EdictType.vz) { bar = "|さ"; } if (polite != 0) { if (affirmative != 0) { return(VerbStem.aForm(radical, type) + bar + "せられます"); } return(VerbStem.aForm(radical, type) + bar + "せられません"); } //plain if (affirmative != 0) { return(VerbStem.aForm(radical, type) + bar + "せられる"); } return(VerbStem.aForm(radical, type) + bar + "せられない"); } return(verb); }
public static string Conjugate(string verb, EdictType type, CForm form, Politeness polite = Politeness.Plain, Polarity affirmative = Polarity.Affirmative) { return(Inflection.Conjugate(verb, type, form, polite, affirmative)); }