public static bool IsGodan(EdictType type) { switch (type) { case EdictType.v5: case EdictType.v5aru: case EdictType.v5b: case EdictType.v5g: case EdictType.v5k: case EdictType.v5k_s: case EdictType.v5m: case EdictType.v5n: case EdictType.v5r: case EdictType.v5r_i: case EdictType.v5s: case EdictType.v5t: case EdictType.v5u: case EdictType.v5u_s: case EdictType.v5uru: case EdictType.v5z: return(true); default: return(false); } }
public static string ToLongString(this EdictType type) { if (inverseMapping.TryGetValue(type, out var value)) { return(value); } return(type.ToString()); }
/*! \~english * @brief eImpForm Gives the e-imperative form (stem) of a verb * * It is the same as eImpForm, but in case of suru and kuru, ichidan, and zuru it's different * eg. する -> しろ * @param radical It is the part which never get changed during conjugation, * we can get it dictionary form (u-form) minus the last character (eg. 飲む -> 飲) * @param type type of the verb: v1, v5u, etc. (See EdictType) * @return string the e-imperative form of the verb */ public static string eImpForm(string radical, EdictType type) { switch (type) { case EdictType.v0: //just the radical return(radical); case EdictType.v1: //Ichidan verb return(radical + "|(ろ/よ)"); case EdictType.v1_s: //Ichidan verb - kureru special class return(radical + "|"); case EdictType.v2a_s: //Nidan verb with 'u' ending (archaic) return(radical); //TODO: check case EdictType.v4h: //Yondan verb with 'hu/fu' ending (archaic) return(radical); //TODO: check case EdictType.v4r: //Yondan verb with 'ru' ending (archaic) return(radical); //TODO: check case EdictType.v5aru: //Godan verb - -aru special class return(radical + "|い"); case EdictType.vz: //Ichidan verb - zuru verb - (alternative form of -jiru verbs) radical = Utils.Chop(radical, 1); return(radical + "|(じろ/じよ/ぜよ)"); case EdictType.vk: //kuru verb - special class if (radical.EndsWith("く")) { radical = Utils.Chop(radical, 1); radical += "こ"; } return(radical + "|い"); case EdictType.vs: //noun or participle which takes the aux. verb suru radical = Utils.Chop(radical, 1); return(radical + "|(しろ/せよ)"); case EdictType.vs_c: //su verb - precursor to the modern suru return(radical + "|せよ"); case EdictType.vs_i: //suru verb - irregular radical = Utils.Chop(radical, 1); return(radical + "|(しろ/せよ)"); case EdictType.vs_s: //suru verb - special class radical = Utils.Chop(radical, 1); return(radical + "|(しろ/せよ)"); } //if not included in special cases, the form is same as eForm return(eForm(radical, type)); }
public static bool IsIchidan(EdictType type) { switch (type) { case EdictType.v1: case EdictType.v1_s: return(true); } return(false); }
public static bool IsSuru(EdictType type) { switch (type) { case EdictType.vs: case EdictType.vs_c: case EdictType.vs_i: case EdictType.vs_s: return(true); } return(false); }
/// <summary> /// PR_ValueString /// </summary> private unsafe String ValueString(EdictType type, void *val) { String result; type &= (EdictType) ~ProgramDef.DEF_SAVEGLOBAL; switch (type) { case EdictType.ev_string: result = GetString(*( Int32 * )val); break; case EdictType.ev_entity: result = "entity " + Host.Server.NumForEdict(Host.Server.ProgToEdict(*( Int32 * )val)); break; case EdictType.ev_function: var f = _Functions[*( Int32 * )val]; result = GetString(f.s_name) + "()"; break; case EdictType.ev_field: var def = FindField(*( Int32 * )val); result = "." + GetString(def.s_name); break; case EdictType.ev_void: result = "void"; break; case EdictType.ev_float: result = (*( Single * )val).ToString("F1", CultureInfo.InvariantCulture.NumberFormat); break; case EdictType.ev_vector: result = String.Format(CultureInfo.InvariantCulture.NumberFormat, "{0,5:F1} {1,5:F1} {2,5:F1}", (( Single * )val)[0], (( Single * )val)[1], (( Single * )val)[2]); break; case EdictType.ev_pointer: result = "pointer"; break; default: result = "bad type " + type.ToString( ); break; } return(result); }
/// <summary> /// PR_UglyValueString /// Returns a string describing *data in a type specific manner /// Easier to parse than PR_ValueString /// </summary> private unsafe String UglyValueString(EdictType type, EVal *val) { type &= (EdictType) ~ProgramDef.DEF_SAVEGLOBAL; String result; switch (type) { case EdictType.ev_string: result = GetString(val->_string); break; case EdictType.ev_entity: result = Host.Server.NumForEdict(Host.Server.ProgToEdict(val->edict)).ToString( ); break; case EdictType.ev_function: var f = _Functions[val->function]; result = GetString(f.s_name); break; case EdictType.ev_field: var def = FindField(val->_int); result = GetString(def.s_name); break; case EdictType.ev_void: result = "void"; break; case EdictType.ev_float: result = val->_float.ToString("F6", CultureInfo.InvariantCulture.NumberFormat); break; case EdictType.ev_vector: result = String.Format(CultureInfo.InvariantCulture.NumberFormat, "{0:F6} {1:F6} {2:F6}", val->vector[0], val->vector[1], val->vector[2]); break; default: result = "bad type " + type.ToString( ); break; } return(result); }
public static string Katsuyou(string verb, EdictType type, KForm form) { if (verb.Length < 2) { return(verb); } string radical = verb; radical = Utils.Chop(radical, 1); switch (form) { case KForm.ImperfectiveA: return(VerbStem.aForm(radical, type)); case KForm.ImperfectiveO: return(VerbStem.oForm(radical, type)); case KForm.ConjunctiveI: return(VerbStem.iForm(radical, type)); case KForm.ConjunctiveT: return(VerbStem.tForm(radical, type)); case KForm.TerminalU: return(VerbStem.uForm(radical, type)); case KForm.AttributiveU: return(VerbStem.uForm(radical, type)); case KForm.HypotheticalE: return(VerbStem.eForm(radical, type)); case KForm.ImperativeE: return(VerbStem.eImpForm(radical, type)); } return(verb); }
public Word(string text, EdictType type) { Text = text; Type = type; }
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); }
/*! \~english * @brief oForm Gives the o-form (stem) of a verb * * The function take a \e radical \e of a verb and gives its o-form by changing the last character's sound * from \b u \b (dictionary form) to \b o \b \n * eg. 飲む -> 飲も * @param radical It is the part which never get changed during conjugation, * we can get it dictionary form (u-form) minus the last character (eg. 飲む -> 飲) * @param type type of the verb: v1, v5u, etc. (See EdictType) * @return string the o-form of the verb */ public static string oForm(string radical, EdictType type) { radical += "|"; switch (type) { case EdictType.v0: //just the radical radical = Utils.Chop(radical, 1); return(radical); case EdictType.v1: //Ichidan verb case EdictType.v1_s: //Ichidan verb - kureru special class return(radical); case EdictType.v2a_s: //Nidan verb with 'u' ending (archaic) return(radical); //TODO: check case EdictType.v4h: //Yondan verb with 'hu/fu' ending (archaic) return(radical); //TODO: check case EdictType.v4r: //Yondan verb with 'ru' ending (archaic) return(radical); //TODO: check case EdictType.v5: //Godan verb (not completely classified) return(radical); //TODO: check case EdictType.v5aru: //Godan verb - -aru special class return(radical + "ろ"); case EdictType.v5b: //Godan verb with 'bu' ending return(radical + "ぼ"); case EdictType.v5g: //Godan verb with 'gu' ending return(radical + "ご"); case EdictType.v5k: //Godan verb with 'ku' ending return(radical + "こ"); case EdictType.v5k_s: //Godan verb - iku/yuku special class return(radical + "こ"); case EdictType.v5m: //Godan verb with 'mu' ending return(radical + "も"); case EdictType.v5n: //Godan verb with 'nu' ending return(radical + "の"); case EdictType.v5r: //Godan verb with 'ru' ending return(radical + "ろ"); case EdictType.v5r_i: //Godan verb with 'ru' ending (irregular verb) ある radical = Utils.Chop(radical, 2); return(radical + "|あり"); case EdictType.v5s: //Godan verb with 'su' ending return(radical + "そ"); case EdictType.v5t: //Godan verb with 'tsu' ending return(radical + "と"); case EdictType.v5u: //Godan verb with 'u' ending return(radical + "お"); case EdictType.v5u_s: //Godan verb with 'u' ending (special class) こう とう return(radical + "お"); case EdictType.v5uru: //Godan verb - uru old class verb (old form of Eru) return(radical + "ろ"); case EdictType.v5z: //Godan verb with 'zu' ending return(radical + "ず"); case EdictType.vz: //Ichidan verb - zuru verb - (alternative form of -jiru verbs) radical = Utils.Chop(radical, 2); return(radical + "|じ"); case EdictType.vk: //kuru verb - special class if (radical.EndsWith("く|")) { radical = Utils.Chop(radical, 2); return(radical + "こ|"); } return(radical); case EdictType.vn: //irregular nu verb 死ぬ return(radical + "の"); case EdictType.vs: //noun or participle which takes the aux. verb suru radical = Utils.Chop(radical, 2); return(radical + "|し"); case EdictType.vs_c: //su verb - precursor to the modern suru return(radical + "し"); case EdictType.vs_i: //suru verb - irregular radical = Utils.Chop(radical, 2); return(radical + "|し"); case EdictType.vs_s: //suru verb - special class radical = Utils.Chop(radical, 2); return(radical + "|し"); } return(radical); }
public static bool IsNoun(this EdictType type) { return((int)type < 256 && (int)type >= (int)EdictType.n); }
public static bool IsVerb(this EdictType type) { return((int)type < (int)EdictType.n); }
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)); }
public static string Katsuyou(string verb, EdictType type, KForm form) { return(Inflection.Katsuyou(verb, type, form)); }