#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 txb_drop(el_val_t s, el_val_t n); el_val_t txb_ends(el_val_t s, el_val_t suf); el_val_t txb_slot(el_val_t person, el_val_t number); el_val_t txb_pres1_suffix(el_val_t slot); el_val_t txb_kam_present(el_val_t slot); el_val_t txb_ya_present(el_val_t slot); el_val_t txb_wes_present(el_val_t slot); el_val_t txb_lyut_present(el_val_t slot); el_val_t txb_wak_present(el_val_t slot); el_val_t txb_map_canonical(el_val_t verb); el_val_t txb_conjugate(el_val_t verb, el_val_t tense, el_val_t person, el_val_t number); el_val_t txb_decline_masc(el_val_t noun, el_val_t gram_case, el_val_t number); el_val_t txb_decline_fem(el_val_t noun, el_val_t gram_case, el_val_t number); el_val_t txb_detect_gender(el_val_t noun); el_val_t txb_decline(el_val_t noun, el_val_t gram_case, el_val_t number); el_val_t txb_noun_phrase(el_val_t noun, el_val_t gram_case, el_val_t number, el_val_t definite); el_val_t txb_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 txb_ends(el_val_t s, el_val_t suf) { return str_ends_with(s, suf); return 0; } el_val_t txb_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 txb_pres1_suffix(el_val_t slot) { if (slot == 0) { return EL_STR("au"); } if (slot == 1) { return EL_STR("\xc3\xa4t"); } if (slot == 2) { return EL_STR("em"); } if (slot == 3) { return EL_STR("emane"); } if (slot == 4) { return EL_STR("em"); } return EL_STR("em"); return 0; } el_val_t txb_kam_present(el_val_t slot) { if (slot == 0) { return EL_STR("kam"); } if (slot == 1) { return EL_STR("k\xc3\xa4m"); } if (slot == 2) { return EL_STR("k\xc3\xa4m"); } if (slot == 3) { return EL_STR("kamn\xc3\xa4\xe1\xb9\x83"); } if (slot == 4) { return EL_STR("kamn\xc3\xa4\xe1\xb9\x83"); } return EL_STR("kamn\xc3\xa4\xe1\xb9\x83"); return 0; } el_val_t txb_ya_present(el_val_t slot) { if (slot == 0) { return EL_STR("yau"); } if (slot == 1) { return EL_STR("y\xc3\xa4t"); } if (slot == 2) { return EL_STR("y\xc3\xa4m"); } if (slot == 3) { return EL_STR("ym\xc3\xa4\xe1\xb9\x83"); } if (slot == 4) { return EL_STR("ym\xc3\xa4\xe1\xb9\x83"); } return EL_STR("y\xc3\xa4nm\xc3\xa4\xe1\xb9\x83"); return 0; } el_val_t txb_wes_present(el_val_t slot) { if (slot == 2) { return EL_STR("ste"); } return EL_STR("wes"); return 0; } el_val_t txb_lyut_present(el_val_t slot) { if (slot == 0) { return EL_STR("lyutau"); } if (slot == 1) { return EL_STR("lyut\xc3\xa4t"); } if (slot == 2) { return EL_STR("lyutem"); } if (slot == 3) { return EL_STR("lyutemane"); } if (slot == 4) { return EL_STR("lyutem"); } return EL_STR("lyutem"); return 0; } el_val_t txb_wak_present(el_val_t slot) { if (slot == 0) { return EL_STR("wakau"); } if (slot == 1) { return EL_STR("wak\xc3\xa4t"); } if (slot == 2) { return EL_STR("wakem"); } if (slot == 3) { return EL_STR("wakemane"); } if (slot == 4) { return EL_STR("wakem"); } return EL_STR("wakem"); return 0; } el_val_t txb_map_canonical(el_val_t verb) { if (str_eq(verb, EL_STR("be"))) { return EL_STR("wes"); } if (str_eq(verb, EL_STR("come"))) { return EL_STR("k\xc3\xa4m"); } if (str_eq(verb, EL_STR("go"))) { return EL_STR("y\xc3\xa4"); } if (str_eq(verb, EL_STR("see"))) { return EL_STR("lyut"); } if (str_eq(verb, EL_STR("speak"))) { return EL_STR("wak"); } if (str_eq(verb, EL_STR("say"))) { return EL_STR("wak"); } return verb; return 0; } el_val_t txb_conjugate(el_val_t verb, el_val_t tense, el_val_t person, el_val_t number) { el_val_t v = txb_map_canonical(verb); el_val_t slot = txb_slot(person, number); if (str_eq(v, EL_STR("wes"))) { if (str_eq(tense, EL_STR("present"))) { return txb_wes_present(slot); } return v; } if (str_eq(v, EL_STR("k\xc3\xa4m"))) { if (str_eq(tense, EL_STR("present"))) { return txb_kam_present(slot); } return v; } if (str_eq(v, EL_STR("y\xc3\xa4"))) { if (str_eq(tense, EL_STR("present"))) { return txb_ya_present(slot); } return v; } if (str_eq(v, EL_STR("lyut"))) { if (str_eq(tense, EL_STR("present"))) { return txb_lyut_present(slot); } return v; } if (str_eq(v, EL_STR("wak"))) { if (str_eq(tense, EL_STR("present"))) { return txb_wak_present(slot); } return v; } if (str_eq(tense, EL_STR("present"))) { return el_str_concat(v, txb_pres1_suffix(slot)); } return v; return 0; } el_val_t txb_decline_masc(el_val_t noun, 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_concat(noun, EL_STR("e")); } if (str_eq(gram_case, EL_STR("accusative"))) { return el_str_concat(noun, EL_STR("e")); } if (str_eq(gram_case, EL_STR("genitive"))) { return el_str_concat(noun, EL_STR("entse")); } if (str_eq(gram_case, EL_STR("dative"))) { return el_str_concat(noun, EL_STR("ene")); } return el_str_concat(noun, EL_STR("e")); } if (str_eq(gram_case, EL_STR("nominative"))) { return el_str_concat(noun, EL_STR("i")); } if (str_eq(gram_case, EL_STR("accusative"))) { return el_str_concat(noun, EL_STR("i")); } if (str_eq(gram_case, EL_STR("genitive"))) { return el_str_concat(noun, EL_STR("entwetse")); } if (str_eq(gram_case, EL_STR("dative"))) { return el_str_concat(noun, EL_STR("ene")); } return el_str_concat(noun, EL_STR("i")); return 0; } el_val_t txb_decline_fem(el_val_t noun, 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_concat(noun, EL_STR("a")); } if (str_eq(gram_case, EL_STR("accusative"))) { return el_str_concat(noun, EL_STR("a")); } if (str_eq(gram_case, EL_STR("genitive"))) { return el_str_concat(noun, EL_STR("antse")); } if (str_eq(gram_case, EL_STR("dative"))) { return el_str_concat(noun, EL_STR("ane")); } return el_str_concat(noun, EL_STR("a")); } if (str_eq(gram_case, EL_STR("nominative"))) { return el_str_concat(noun, EL_STR("\xc3\xa4")); } if (str_eq(gram_case, EL_STR("accusative"))) { return el_str_concat(noun, EL_STR("\xc3\xa4")); } if (str_eq(gram_case, EL_STR("genitive"))) { return el_str_concat(noun, EL_STR("antse")); } if (str_eq(gram_case, EL_STR("dative"))) { return el_str_concat(noun, EL_STR("ane")); } return el_str_concat(noun, EL_STR("\xc3\xa4")); return 0; } el_val_t txb_detect_gender(el_val_t noun) { return EL_STR("masculine"); return 0; } el_val_t txb_decline(el_val_t noun, el_val_t gram_case, el_val_t number) { el_val_t gender = txb_detect_gender(noun); if (str_eq(gender, EL_STR("feminine"))) { return txb_decline_fem(noun, gram_case, number); } return txb_decline_masc(noun, gram_case, number); return 0; } el_val_t txb_noun_phrase(el_val_t noun, el_val_t gram_case, el_val_t number, el_val_t definite) { return txb_decline(noun, gram_case, number); return 0; }