#include #include #include "el_runtime.h" el_val_t str_ends(el_val_t s, el_val_t suf); el_val_t str_last_char(el_val_t s); el_val_t str_last2(el_val_t s); el_val_t str_last3(el_val_t s); el_val_t str_drop_last(el_val_t s, el_val_t n); el_val_t is_vowel(el_val_t c); el_val_t morph_apply_suffix(el_val_t base, el_val_t suffix); el_val_t en_irregular_plural(el_val_t word); el_val_t en_irregular_singular(el_val_t word); el_val_t en_irregular_verb(el_val_t base); el_val_t en_verb_3sg(el_val_t base); el_val_t en_should_double_final(el_val_t base); el_val_t en_verb_past(el_val_t base); el_val_t en_verb_gerund(el_val_t base); el_val_t en_pluralize_regular(el_val_t singular); el_val_t en_verb_form(el_val_t base, el_val_t tense, el_val_t person, el_val_t number); el_val_t agree_determiner(el_val_t det, el_val_t noun); el_val_t morph_pluralize(el_val_t noun, el_val_t profile); el_val_t morph_map_canonical(el_val_t verb, el_val_t code); el_val_t morph_conjugate(el_val_t verb, el_val_t tense, el_val_t person, el_val_t number, el_val_t profile); el_val_t morph_inflect(el_val_t word, el_val_t features, el_val_t profile); el_val_t pluralize(el_val_t singular); el_val_t singularize(el_val_t plural); el_val_t verb_form(el_val_t base, el_val_t tense, el_val_t person, el_val_t number); el_val_t irregular_plural(el_val_t word); el_val_t irregular_singular(el_val_t word); el_val_t non_str_ends(el_val_t s, el_val_t suf); el_val_t non_drop(el_val_t s, el_val_t n); el_val_t non_last(el_val_t s); el_val_t non_slot(el_val_t person, el_val_t number); el_val_t non_vera_present(el_val_t slot); el_val_t non_vera_past(el_val_t slot); el_val_t non_hafa_present(el_val_t slot); el_val_t non_hafa_past(el_val_t slot); el_val_t non_ganga_present(el_val_t slot); el_val_t non_ganga_past(el_val_t slot); el_val_t non_sja_present(el_val_t slot); el_val_t non_sja_past(el_val_t slot); el_val_t non_segja_present(el_val_t slot); el_val_t non_segja_past(el_val_t slot); el_val_t non_koma_present(el_val_t slot); el_val_t non_koma_past(el_val_t slot); el_val_t non_map_canonical(el_val_t verb); el_val_t non_weak_present(el_val_t stem, el_val_t slot); el_val_t non_weak_past(el_val_t stem, el_val_t slot); el_val_t non_conjugate(el_val_t verb, el_val_t tense, el_val_t person, el_val_t number); el_val_t non_decline_masc(el_val_t noun, el_val_t gram_case, el_val_t number); el_val_t non_decline_fem(el_val_t noun, el_val_t gram_case, el_val_t number); el_val_t non_decline_neut(el_val_t noun, el_val_t gram_case, el_val_t number); el_val_t non_detect_gender(el_val_t noun); el_val_t non_decline(el_val_t noun, el_val_t gram_case, el_val_t number); el_val_t non_def_suffix_masc(el_val_t gram_case, el_val_t number); el_val_t non_def_suffix_neut(el_val_t gram_case, el_val_t number); el_val_t non_def_suffix_fem(el_val_t gram_case, el_val_t number); el_val_t non_noun_phrase(el_val_t noun, el_val_t gram_case, el_val_t number, el_val_t definite); el_val_t non_str_ends(el_val_t s, el_val_t suf) { return str_ends_with(s, suf); return 0; } el_val_t non_drop(el_val_t s, el_val_t n) { el_val_t len = str_len(s); if (n >= len) { return EL_STR(""); } return str_slice(s, 0, (len - n)); return 0; } el_val_t non_last(el_val_t s) { el_val_t n = str_len(s); if (n == 0) { return EL_STR(""); } return str_slice(s, (n - 1), n); return 0; } el_val_t non_slot(el_val_t person, el_val_t number) { if (str_eq(person, EL_STR("first"))) { if (str_eq(number, EL_STR("singular"))) { return 0; } return 3; } if (str_eq(person, EL_STR("second"))) { if (str_eq(number, EL_STR("singular"))) { return 1; } return 4; } if (str_eq(number, EL_STR("singular"))) { return 2; } return 5; return 0; } el_val_t non_vera_present(el_val_t slot) { if (slot == 0) { return EL_STR("em"); } if (slot == 1) { return EL_STR("ert"); } if (slot == 2) { return EL_STR("er"); } if (slot == 3) { return EL_STR("erum"); } if (slot == 4) { return EL_STR("eru\xc3\xb0"); } return EL_STR("eru"); return 0; } el_val_t non_vera_past(el_val_t slot) { if (slot == 0) { return EL_STR("var"); } if (slot == 1) { return EL_STR("vart"); } if (slot == 2) { return EL_STR("var"); } if (slot == 3) { return EL_STR("v\xc3\xb3rum"); } if (slot == 4) { return EL_STR("v\xc3\xb3ru\xc3\xb0"); } return EL_STR("v\xc3\xb3ru"); return 0; } el_val_t non_hafa_present(el_val_t slot) { if (slot == 0) { return EL_STR("hefi"); } if (slot == 1) { return EL_STR("hefr"); } if (slot == 2) { return EL_STR("hefr"); } if (slot == 3) { return EL_STR("h\xc3\xb6""fum"); } if (slot == 4) { return EL_STR("hafi\xc3\xb0"); } return EL_STR("hafa"); return 0; } el_val_t non_hafa_past(el_val_t slot) { if (slot == 0) { return EL_STR("haf\xc3\xb0""a"); } if (slot == 1) { return EL_STR("haf\xc3\xb0ir"); } if (slot == 2) { return EL_STR("haf\xc3\xb0i"); } if (slot == 3) { return EL_STR("h\xc3\xb6""f\xc3\xb0um"); } if (slot == 4) { return EL_STR("h\xc3\xb6""f\xc3\xb0u\xc3\xb0"); } return EL_STR("h\xc3\xb6""f\xc3\xb0u"); return 0; } el_val_t non_ganga_present(el_val_t slot) { if (slot == 0) { return EL_STR("geng"); } if (slot == 1) { return EL_STR("gengr"); } if (slot == 2) { return EL_STR("gengr"); } if (slot == 3) { return EL_STR("g\xc3\xb6ngum"); } if (slot == 4) { return EL_STR("gangi\xc3\xb0"); } return EL_STR("ganga"); return 0; } el_val_t non_ganga_past(el_val_t slot) { if (slot == 0) { return EL_STR("gekk"); } if (slot == 1) { return EL_STR("gekkt"); } if (slot == 2) { return EL_STR("gekk"); } if (slot == 3) { return EL_STR("gengum"); } if (slot == 4) { return EL_STR("gengu\xc3\xb0"); } return EL_STR("gengu"); return 0; } el_val_t non_sja_present(el_val_t slot) { if (slot == 0) { return EL_STR("s\xc3\xa9"); } if (slot == 1) { return EL_STR("s\xc3\xa9r"); } if (slot == 2) { return EL_STR("s\xc3\xa9r"); } if (slot == 3) { return EL_STR("s\xc3\xa9um"); } if (slot == 4) { return EL_STR("s\xc3\xa9i\xc3\xb0"); } return EL_STR("sj\xc3\xa1"); return 0; } el_val_t non_sja_past(el_val_t slot) { if (slot == 0) { return EL_STR("s\xc3\xa1"); } if (slot == 1) { return EL_STR("s\xc3\xa1st"); } if (slot == 2) { return EL_STR("s\xc3\xa1"); } if (slot == 3) { return EL_STR("s\xc3\xa1m"); } if (slot == 4) { return EL_STR("s\xc3\xa1\xc3\xb0"); } return EL_STR("s\xc3\xa1u"); return 0; } el_val_t non_segja_present(el_val_t slot) { if (slot == 0) { return EL_STR("segi"); } if (slot == 1) { return EL_STR("segir"); } if (slot == 2) { return EL_STR("segir"); } if (slot == 3) { return EL_STR("segjum"); } if (slot == 4) { return EL_STR("segi\xc3\xb0"); } return EL_STR("segja"); return 0; } el_val_t non_segja_past(el_val_t slot) { if (slot == 0) { return EL_STR("sag\xc3\xb0i"); } if (slot == 1) { return EL_STR("sag\xc3\xb0ir"); } if (slot == 2) { return EL_STR("sag\xc3\xb0i"); } if (slot == 3) { return EL_STR("s\xc3\xb6g\xc3\xb0um"); } if (slot == 4) { return EL_STR("s\xc3\xb6g\xc3\xb0u\xc3\xb0"); } return EL_STR("s\xc3\xb6g\xc3\xb0u"); return 0; } el_val_t non_koma_present(el_val_t slot) { if (slot == 0) { return EL_STR("kem"); } if (slot == 1) { return EL_STR("kemr"); } if (slot == 2) { return EL_STR("kemr"); } if (slot == 3) { return EL_STR("komum"); } if (slot == 4) { return EL_STR("komi\xc3\xb0"); } return EL_STR("koma"); return 0; } el_val_t non_koma_past(el_val_t slot) { if (slot == 0) { return EL_STR("kom"); } if (slot == 1) { return EL_STR("komt"); } if (slot == 2) { return EL_STR("kom"); } if (slot == 3) { return EL_STR("komum"); } if (slot == 4) { return EL_STR("komu\xc3\xb0"); } return EL_STR("komu"); return 0; } el_val_t non_map_canonical(el_val_t verb) { if (str_eq(verb, EL_STR("be"))) { return EL_STR("vera"); } if (str_eq(verb, EL_STR("have"))) { return EL_STR("hafa"); } if (str_eq(verb, EL_STR("go"))) { return EL_STR("ganga"); } if (str_eq(verb, EL_STR("see"))) { return EL_STR("sj\xc3\xa1"); } if (str_eq(verb, EL_STR("say"))) { return EL_STR("segja"); } if (str_eq(verb, EL_STR("come"))) { return EL_STR("koma"); } return verb; return 0; } el_val_t non_weak_present(el_val_t stem, el_val_t slot) { if (slot == 0) { return el_str_concat(stem, EL_STR("a")); } if (slot == 1) { return el_str_concat(stem, EL_STR("ar")); } if (slot == 2) { return el_str_concat(stem, EL_STR("ar")); } if (slot == 3) { return el_str_concat(stem, EL_STR("um")); } if (slot == 4) { return el_str_concat(stem, EL_STR("i\xc3\xb0")); } return el_str_concat(stem, EL_STR("a")); return 0; } el_val_t non_weak_past(el_val_t stem, el_val_t slot) { if (slot == 0) { return el_str_concat(stem, EL_STR("a\xc3\xb0i")); } if (slot == 1) { return el_str_concat(stem, EL_STR("a\xc3\xb0ir")); } if (slot == 2) { return el_str_concat(stem, EL_STR("a\xc3\xb0i")); } if (slot == 3) { return el_str_concat(stem, EL_STR("u\xc3\xb0um")); } if (slot == 4) { return el_str_concat(stem, EL_STR("u\xc3\xb0u\xc3\xb0")); } return el_str_concat(stem, EL_STR("u\xc3\xb0u")); return 0; } el_val_t non_conjugate(el_val_t verb, el_val_t tense, el_val_t person, el_val_t number) { el_val_t v = non_map_canonical(verb); el_val_t slot = non_slot(person, number); if (str_eq(v, EL_STR("vera"))) { if (str_eq(tense, EL_STR("present"))) { return non_vera_present(slot); } if (str_eq(tense, EL_STR("past"))) { return non_vera_past(slot); } return v; } if (str_eq(v, EL_STR("hafa"))) { if (str_eq(tense, EL_STR("present"))) { return non_hafa_present(slot); } if (str_eq(tense, EL_STR("past"))) { return non_hafa_past(slot); } return v; } if (str_eq(v, EL_STR("ganga"))) { if (str_eq(tense, EL_STR("present"))) { return non_ganga_present(slot); } if (str_eq(tense, EL_STR("past"))) { return non_ganga_past(slot); } return v; } if (str_eq(v, EL_STR("sj\xc3\xa1"))) { if (str_eq(tense, EL_STR("present"))) { return non_sja_present(slot); } if (str_eq(tense, EL_STR("past"))) { return non_sja_past(slot); } return v; } if (str_eq(v, EL_STR("segja"))) { if (str_eq(tense, EL_STR("present"))) { return non_segja_present(slot); } if (str_eq(tense, EL_STR("past"))) { return non_segja_past(slot); } return v; } if (str_eq(v, EL_STR("koma"))) { if (str_eq(tense, EL_STR("present"))) { return non_koma_present(slot); } if (str_eq(tense, EL_STR("past"))) { return non_koma_past(slot); } return v; } if (non_str_ends(v, EL_STR("a"))) { el_val_t stem = non_drop(v, 1); if (str_eq(tense, EL_STR("present"))) { return non_weak_present(stem, slot); } if (str_eq(tense, EL_STR("past"))) { return non_weak_past(stem, slot); } return v; } return v; return 0; } el_val_t non_decline_masc(el_val_t noun, el_val_t gram_case, el_val_t number) { el_val_t stem = noun; if (non_str_ends(noun, EL_STR("r"))) { stem = non_drop(noun, 1); } if (str_eq(noun, EL_STR("armr"))) { if (str_eq(number, EL_STR("singular"))) { if (str_eq(gram_case, EL_STR("nominative"))) { return EL_STR("armr"); } if (str_eq(gram_case, EL_STR("accusative"))) { return EL_STR("arm"); } if (str_eq(gram_case, EL_STR("genitive"))) { return EL_STR("arms"); } if (str_eq(gram_case, EL_STR("dative"))) { return EL_STR("armi"); } return EL_STR("armr"); } if (str_eq(gram_case, EL_STR("nominative"))) { return EL_STR("armar"); } if (str_eq(gram_case, EL_STR("accusative"))) { return EL_STR("arma"); } if (str_eq(gram_case, EL_STR("genitive"))) { return EL_STR("arma"); } if (str_eq(gram_case, EL_STR("dative"))) { return EL_STR("\xc3\xb6rmum"); } return EL_STR("armar"); } if (str_eq(number, EL_STR("singular"))) { if (str_eq(gram_case, EL_STR("nominative"))) { return el_str_concat(stem, EL_STR("r")); } if (str_eq(gram_case, EL_STR("accusative"))) { return stem; } if (str_eq(gram_case, EL_STR("genitive"))) { return el_str_concat(stem, EL_STR("s")); } if (str_eq(gram_case, EL_STR("dative"))) { return el_str_concat(stem, EL_STR("i")); } return el_str_concat(stem, EL_STR("r")); } if (str_eq(gram_case, EL_STR("nominative"))) { return el_str_concat(stem, EL_STR("ar")); } if (str_eq(gram_case, EL_STR("accusative"))) { return el_str_concat(stem, EL_STR("a")); } if (str_eq(gram_case, EL_STR("genitive"))) { return el_str_concat(stem, EL_STR("a")); } if (str_eq(gram_case, EL_STR("dative"))) { return el_str_concat(stem, EL_STR("um")); } return el_str_concat(stem, EL_STR("ar")); return 0; } el_val_t non_decline_fem(el_val_t noun, el_val_t gram_case, el_val_t number) { if (str_eq(noun, EL_STR("g\xc3\xb6r"))) { if (str_eq(number, EL_STR("singular"))) { if (str_eq(gram_case, EL_STR("nominative"))) { return EL_STR("g\xc3\xb6r"); } if (str_eq(gram_case, EL_STR("accusative"))) { return EL_STR("g\xc3\xb6rvar"); } if (str_eq(gram_case, EL_STR("genitive"))) { return EL_STR("g\xc3\xb6rvar"); } if (str_eq(gram_case, EL_STR("dative"))) { return EL_STR("g\xc3\xb6rvi"); } return EL_STR("g\xc3\xb6r"); } if (str_eq(gram_case, EL_STR("nominative"))) { return EL_STR("g\xc3\xb6rvar"); } if (str_eq(gram_case, EL_STR("accusative"))) { return EL_STR("g\xc3\xb6rvar"); } if (str_eq(gram_case, EL_STR("genitive"))) { return EL_STR("g\xc3\xb6rva"); } if (str_eq(gram_case, EL_STR("dative"))) { return EL_STR("g\xc3\xb6rvum"); } return EL_STR("g\xc3\xb6rvar"); } if (str_eq(number, EL_STR("singular"))) { if (str_eq(gram_case, EL_STR("nominative"))) { return noun; } if (str_eq(gram_case, EL_STR("accusative"))) { return el_str_concat(noun, EL_STR("var")); } if (str_eq(gram_case, EL_STR("genitive"))) { return el_str_concat(noun, EL_STR("var")); } if (str_eq(gram_case, EL_STR("dative"))) { return el_str_concat(noun, EL_STR("vi")); } return noun; } if (str_eq(gram_case, EL_STR("nominative"))) { return el_str_concat(noun, EL_STR("var")); } if (str_eq(gram_case, EL_STR("accusative"))) { return el_str_concat(noun, EL_STR("var")); } if (str_eq(gram_case, EL_STR("genitive"))) { return el_str_concat(noun, EL_STR("va")); } if (str_eq(gram_case, EL_STR("dative"))) { return el_str_concat(noun, EL_STR("vum")); } return el_str_concat(noun, EL_STR("var")); return 0; } el_val_t non_decline_neut(el_val_t noun, el_val_t gram_case, el_val_t number) { if (str_eq(noun, EL_STR("land"))) { if (str_eq(number, EL_STR("singular"))) { if (str_eq(gram_case, EL_STR("nominative"))) { return EL_STR("land"); } if (str_eq(gram_case, EL_STR("accusative"))) { return EL_STR("land"); } if (str_eq(gram_case, EL_STR("genitive"))) { return EL_STR("lands"); } if (str_eq(gram_case, EL_STR("dative"))) { return EL_STR("landi"); } return EL_STR("land"); } if (str_eq(gram_case, EL_STR("nominative"))) { return EL_STR("l\xc3\xb6nd"); } if (str_eq(gram_case, EL_STR("accusative"))) { return EL_STR("l\xc3\xb6nd"); } if (str_eq(gram_case, EL_STR("genitive"))) { return EL_STR("landa"); } if (str_eq(gram_case, EL_STR("dative"))) { return EL_STR("l\xc3\xb6ndum"); } return EL_STR("l\xc3\xb6nd"); } if (str_eq(number, EL_STR("singular"))) { if (str_eq(gram_case, EL_STR("nominative"))) { return noun; } if (str_eq(gram_case, EL_STR("accusative"))) { return noun; } if (str_eq(gram_case, EL_STR("genitive"))) { return el_str_concat(noun, EL_STR("s")); } if (str_eq(gram_case, EL_STR("dative"))) { return el_str_concat(noun, EL_STR("i")); } return noun; } if (str_eq(gram_case, EL_STR("nominative"))) { return noun; } if (str_eq(gram_case, EL_STR("accusative"))) { return noun; } if (str_eq(gram_case, EL_STR("genitive"))) { return el_str_concat(noun, EL_STR("a")); } if (str_eq(gram_case, EL_STR("dative"))) { return el_str_concat(noun, EL_STR("um")); } return noun; return 0; } el_val_t non_detect_gender(el_val_t noun) { if (str_eq(noun, EL_STR("land"))) { return EL_STR("neuter"); } if (str_eq(noun, EL_STR("g\xc3\xb6r"))) { return EL_STR("feminine"); } return EL_STR("masculine"); return 0; } el_val_t non_decline(el_val_t noun, el_val_t gram_case, el_val_t number) { el_val_t gender = non_detect_gender(noun); if (str_eq(gender, EL_STR("masculine"))) { return non_decline_masc(noun, gram_case, number); } if (str_eq(gender, EL_STR("feminine"))) { return non_decline_fem(noun, gram_case, number); } if (str_eq(gender, EL_STR("neuter"))) { return non_decline_neut(noun, gram_case, number); } return noun; return 0; } el_val_t non_def_suffix_masc(el_val_t gram_case, el_val_t number) { if (str_eq(number, EL_STR("singular"))) { if (str_eq(gram_case, EL_STR("nominative"))) { return EL_STR("inn"); } if (str_eq(gram_case, EL_STR("genitive"))) { return EL_STR("ins"); } if (str_eq(gram_case, EL_STR("dative"))) { return EL_STR("inum"); } if (str_eq(gram_case, EL_STR("accusative"))) { return EL_STR("inn"); } return EL_STR("inn"); } if (str_eq(gram_case, EL_STR("nominative"))) { return EL_STR("inir"); } if (str_eq(gram_case, EL_STR("accusative"))) { return EL_STR("ina"); } if (str_eq(gram_case, EL_STR("genitive"))) { return EL_STR("anna"); } if (str_eq(gram_case, EL_STR("dative"))) { return EL_STR("unum"); } return EL_STR("inir"); return 0; } el_val_t non_def_suffix_neut(el_val_t gram_case, el_val_t number) { if (str_eq(number, EL_STR("singular"))) { if (str_eq(gram_case, EL_STR("nominative"))) { return EL_STR("it"); } if (str_eq(gram_case, EL_STR("genitive"))) { return EL_STR("ins"); } if (str_eq(gram_case, EL_STR("dative"))) { return EL_STR("inu"); } if (str_eq(gram_case, EL_STR("accusative"))) { return EL_STR("it"); } return EL_STR("it"); } if (str_eq(gram_case, EL_STR("nominative"))) { return EL_STR("in"); } if (str_eq(gram_case, EL_STR("accusative"))) { return EL_STR("in"); } if (str_eq(gram_case, EL_STR("genitive"))) { return EL_STR("anna"); } if (str_eq(gram_case, EL_STR("dative"))) { return EL_STR("unum"); } return EL_STR("in"); return 0; } el_val_t non_def_suffix_fem(el_val_t gram_case, el_val_t number) { if (str_eq(number, EL_STR("singular"))) { if (str_eq(gram_case, EL_STR("nominative"))) { return EL_STR("in"); } if (str_eq(gram_case, EL_STR("genitive"))) { return EL_STR("innar"); } if (str_eq(gram_case, EL_STR("dative"))) { return EL_STR("inni"); } if (str_eq(gram_case, EL_STR("accusative"))) { return EL_STR("ina"); } return EL_STR("in"); } if (str_eq(gram_case, EL_STR("nominative"))) { return EL_STR("inar"); } if (str_eq(gram_case, EL_STR("accusative"))) { return EL_STR("inar"); } if (str_eq(gram_case, EL_STR("genitive"))) { return EL_STR("anna"); } if (str_eq(gram_case, EL_STR("dative"))) { return EL_STR("innar"); } return EL_STR("inar"); return 0; } el_val_t non_noun_phrase(el_val_t noun, el_val_t gram_case, el_val_t number, el_val_t definite) { el_val_t base = non_decline(noun, gram_case, number); if (!str_eq(definite, EL_STR("true"))) { return base; } el_val_t gender = non_detect_gender(noun); if (str_eq(gender, EL_STR("masculine"))) { return el_str_concat(base, non_def_suffix_masc(gram_case, number)); } if (str_eq(gender, EL_STR("neuter"))) { return el_str_concat(base, non_def_suffix_neut(gram_case, number)); } if (str_eq(gender, EL_STR("feminine"))) { return el_str_concat(base, non_def_suffix_fem(gram_case, number)); } return el_str_concat(base, EL_STR("inn")); return 0; }