Files
neuron/dist/morphology-es.c
will.anderson 48ecd83421 fix: restore elb build — import paths, morphology deps, C master declarations header
- Fix wrong ELP import paths in soul.el, elp-input.el, studio.el
  (../foundation/elp/src → ../foundation/el/elp/src)
- Add missing import "morphology.el" to all 29 language morphology modules
- Recompile all affected dist/*.c with correct cross-module declarations
- Add dist/elp-c-decls.h: C-level master forward declarations for ELP package
  (enables elb --force-include to resolve undeclared cross-module calls)
2026-05-08 19:43:57 -05:00

1055 lines
24 KiB
C

#include <stdint.h>
#include <stdlib.h>
#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 es_str_ends(el_val_t s, el_val_t suf);
el_val_t es_str_drop_last(el_val_t s, el_val_t n);
el_val_t es_str_last_char(el_val_t s);
el_val_t es_str_last2(el_val_t s);
el_val_t es_str_last3(el_val_t s);
el_val_t es_verb_class(el_val_t base);
el_val_t es_stem(el_val_t base);
el_val_t es_slot(el_val_t person, el_val_t number);
el_val_t es_irregular_present(el_val_t verb, el_val_t person, el_val_t number);
el_val_t es_irregular_preterite(el_val_t verb, el_val_t person, el_val_t number);
el_val_t es_irregular_imperfect(el_val_t verb, el_val_t person, el_val_t number);
el_val_t es_regular_present(el_val_t stem, el_val_t vclass, el_val_t slot);
el_val_t es_regular_preterite(el_val_t stem, el_val_t vclass, el_val_t slot);
el_val_t es_regular_future(el_val_t base, el_val_t slot);
el_val_t es_irregular_future_stem(el_val_t verb);
el_val_t es_regular_imperfect(el_val_t stem, el_val_t vclass, el_val_t slot);
el_val_t es_conjugate(el_val_t verb, el_val_t tense, el_val_t person, el_val_t number);
el_val_t es_gender(el_val_t noun);
el_val_t es_invariant_plural(el_val_t noun);
el_val_t es_pluralize(el_val_t noun);
el_val_t es_starts_with_stressed_a(el_val_t noun);
el_val_t es_agree_article(el_val_t noun, el_val_t definite, el_val_t number);
el_val_t es_str_ends(el_val_t s, el_val_t suf) {
return str_ends_with(s, suf);
return 0;
}
el_val_t es_str_drop_last(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 es_str_last_char(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 es_str_last2(el_val_t s) {
el_val_t n = str_len(s);
if (n < 2) {
return s;
}
return str_slice(s, (n - 2), n);
return 0;
}
el_val_t es_str_last3(el_val_t s) {
el_val_t n = str_len(s);
if (n < 3) {
return s;
}
return str_slice(s, (n - 3), n);
return 0;
}
el_val_t es_verb_class(el_val_t base) {
if (es_str_ends(base, EL_STR("ar"))) {
return EL_STR("ar");
}
if (es_str_ends(base, EL_STR("er"))) {
return EL_STR("er");
}
if (es_str_ends(base, EL_STR("ir"))) {
return EL_STR("ir");
}
return EL_STR("ar");
return 0;
}
el_val_t es_stem(el_val_t base) {
return es_str_drop_last(base, 2);
return 0;
}
el_val_t es_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 es_irregular_present(el_val_t verb, el_val_t person, el_val_t number) {
el_val_t slot = es_slot(person, number);
if (str_eq(verb, EL_STR("ser"))) {
if (slot == 0) {
return EL_STR("soy");
}
if (slot == 1) {
return EL_STR("eres");
}
if (slot == 2) {
return EL_STR("es");
}
if (slot == 3) {
return EL_STR("somos");
}
if (slot == 4) {
return EL_STR("sois");
}
return EL_STR("son");
}
if (str_eq(verb, EL_STR("estar"))) {
if (slot == 0) {
return EL_STR("estoy");
}
if (slot == 1) {
return EL_STR("est\xc3\xa1s");
}
if (slot == 2) {
return EL_STR("est\xc3\xa1");
}
if (slot == 3) {
return EL_STR("estamos");
}
if (slot == 4) {
return EL_STR("est\xc3\xa1is");
}
return EL_STR("est\xc3\xa1n");
}
if (str_eq(verb, EL_STR("tener"))) {
if (slot == 0) {
return EL_STR("tengo");
}
if (slot == 1) {
return EL_STR("tienes");
}
if (slot == 2) {
return EL_STR("tiene");
}
if (slot == 3) {
return EL_STR("tenemos");
}
if (slot == 4) {
return EL_STR("ten\xc3\xa9is");
}
return EL_STR("tienen");
}
if (str_eq(verb, EL_STR("hacer"))) {
if (slot == 0) {
return EL_STR("hago");
}
if (slot == 1) {
return EL_STR("haces");
}
if (slot == 2) {
return EL_STR("hace");
}
if (slot == 3) {
return EL_STR("hacemos");
}
if (slot == 4) {
return EL_STR("hac\xc3\xa9is");
}
return EL_STR("hacen");
}
if (str_eq(verb, EL_STR("ir"))) {
if (slot == 0) {
return EL_STR("voy");
}
if (slot == 1) {
return EL_STR("vas");
}
if (slot == 2) {
return EL_STR("va");
}
if (slot == 3) {
return EL_STR("vamos");
}
if (slot == 4) {
return EL_STR("vais");
}
return EL_STR("van");
}
if (str_eq(verb, EL_STR("ver"))) {
if (slot == 0) {
return EL_STR("veo");
}
if (slot == 1) {
return EL_STR("ves");
}
if (slot == 2) {
return EL_STR("ve");
}
if (slot == 3) {
return EL_STR("vemos");
}
if (slot == 4) {
return EL_STR("veis");
}
return EL_STR("ven");
}
if (str_eq(verb, EL_STR("dar"))) {
if (slot == 0) {
return EL_STR("doy");
}
if (slot == 1) {
return EL_STR("das");
}
if (slot == 2) {
return EL_STR("da");
}
if (slot == 3) {
return EL_STR("damos");
}
if (slot == 4) {
return EL_STR("dais");
}
return EL_STR("dan");
}
if (str_eq(verb, EL_STR("saber"))) {
if (slot == 0) {
return EL_STR("s\xc3\xa9");
}
if (slot == 1) {
return EL_STR("sabes");
}
if (slot == 2) {
return EL_STR("sabe");
}
if (slot == 3) {
return EL_STR("sabemos");
}
if (slot == 4) {
return EL_STR("sab\xc3\xa9is");
}
return EL_STR("saben");
}
if (str_eq(verb, EL_STR("poder"))) {
if (slot == 0) {
return EL_STR("puedo");
}
if (slot == 1) {
return EL_STR("puedes");
}
if (slot == 2) {
return EL_STR("puede");
}
if (slot == 3) {
return EL_STR("podemos");
}
if (slot == 4) {
return EL_STR("pod\xc3\xa9is");
}
return EL_STR("pueden");
}
if (str_eq(verb, EL_STR("querer"))) {
if (slot == 0) {
return EL_STR("quiero");
}
if (slot == 1) {
return EL_STR("quieres");
}
if (slot == 2) {
return EL_STR("quiere");
}
if (slot == 3) {
return EL_STR("queremos");
}
if (slot == 4) {
return EL_STR("quer\xc3\xa9is");
}
return EL_STR("quieren");
}
if (str_eq(verb, EL_STR("venir"))) {
if (slot == 0) {
return EL_STR("vengo");
}
if (slot == 1) {
return EL_STR("vienes");
}
if (slot == 2) {
return EL_STR("viene");
}
if (slot == 3) {
return EL_STR("venimos");
}
if (slot == 4) {
return EL_STR("ven\xc3\xads");
}
return EL_STR("vienen");
}
if (str_eq(verb, EL_STR("decir"))) {
if (slot == 0) {
return EL_STR("digo");
}
if (slot == 1) {
return EL_STR("dices");
}
if (slot == 2) {
return EL_STR("dice");
}
if (slot == 3) {
return EL_STR("decimos");
}
if (slot == 4) {
return EL_STR("dec\xc3\xads");
}
return EL_STR("dicen");
}
if (str_eq(verb, EL_STR("haber"))) {
if (slot == 0) {
return EL_STR("he");
}
if (slot == 1) {
return EL_STR("has");
}
if (slot == 2) {
return EL_STR("ha");
}
if (slot == 3) {
return EL_STR("hemos");
}
if (slot == 4) {
return EL_STR("hab\xc3\xa9is");
}
return EL_STR("han");
}
return EL_STR("");
return 0;
}
el_val_t es_irregular_preterite(el_val_t verb, el_val_t person, el_val_t number) {
el_val_t slot = es_slot(person, number);
if (str_eq(verb, EL_STR("ser"))) {
if (slot == 0) {
return EL_STR("fui");
}
if (slot == 1) {
return EL_STR("fuiste");
}
if (slot == 2) {
return EL_STR("fue");
}
if (slot == 3) {
return EL_STR("fuimos");
}
if (slot == 4) {
return EL_STR("fuisteis");
}
return EL_STR("fueron");
}
if (str_eq(verb, EL_STR("ir"))) {
if (slot == 0) {
return EL_STR("fui");
}
if (slot == 1) {
return EL_STR("fuiste");
}
if (slot == 2) {
return EL_STR("fue");
}
if (slot == 3) {
return EL_STR("fuimos");
}
if (slot == 4) {
return EL_STR("fuisteis");
}
return EL_STR("fueron");
}
if (str_eq(verb, EL_STR("tener"))) {
if (slot == 0) {
return EL_STR("tuve");
}
if (slot == 1) {
return EL_STR("tuviste");
}
if (slot == 2) {
return EL_STR("tuvo");
}
if (slot == 3) {
return EL_STR("tuvimos");
}
if (slot == 4) {
return EL_STR("tuvisteis");
}
return EL_STR("tuvieron");
}
if (str_eq(verb, EL_STR("hacer"))) {
if (slot == 0) {
return EL_STR("hice");
}
if (slot == 1) {
return EL_STR("hiciste");
}
if (slot == 2) {
return EL_STR("hizo");
}
if (slot == 3) {
return EL_STR("hicimos");
}
if (slot == 4) {
return EL_STR("hicisteis");
}
return EL_STR("hicieron");
}
if (str_eq(verb, EL_STR("estar"))) {
if (slot == 0) {
return EL_STR("estuve");
}
if (slot == 1) {
return EL_STR("estuviste");
}
if (slot == 2) {
return EL_STR("estuvo");
}
if (slot == 3) {
return EL_STR("estuvimos");
}
if (slot == 4) {
return EL_STR("estuvisteis");
}
return EL_STR("estuvieron");
}
if (str_eq(verb, EL_STR("dar"))) {
if (slot == 0) {
return EL_STR("di");
}
if (slot == 1) {
return EL_STR("diste");
}
if (slot == 2) {
return EL_STR("dio");
}
if (slot == 3) {
return EL_STR("dimos");
}
if (slot == 4) {
return EL_STR("disteis");
}
return EL_STR("dieron");
}
if (str_eq(verb, EL_STR("saber"))) {
if (slot == 0) {
return EL_STR("supe");
}
if (slot == 1) {
return EL_STR("supiste");
}
if (slot == 2) {
return EL_STR("supo");
}
if (slot == 3) {
return EL_STR("supimos");
}
if (slot == 4) {
return EL_STR("supisteis");
}
return EL_STR("supieron");
}
if (str_eq(verb, EL_STR("poder"))) {
if (slot == 0) {
return EL_STR("pude");
}
if (slot == 1) {
return EL_STR("pudiste");
}
if (slot == 2) {
return EL_STR("pudo");
}
if (slot == 3) {
return EL_STR("pudimos");
}
if (slot == 4) {
return EL_STR("pudisteis");
}
return EL_STR("pudieron");
}
if (str_eq(verb, EL_STR("querer"))) {
if (slot == 0) {
return EL_STR("quise");
}
if (slot == 1) {
return EL_STR("quisiste");
}
if (slot == 2) {
return EL_STR("quiso");
}
if (slot == 3) {
return EL_STR("quisimos");
}
if (slot == 4) {
return EL_STR("quisisteis");
}
return EL_STR("quisieron");
}
if (str_eq(verb, EL_STR("venir"))) {
if (slot == 0) {
return EL_STR("vine");
}
if (slot == 1) {
return EL_STR("viniste");
}
if (slot == 2) {
return EL_STR("vino");
}
if (slot == 3) {
return EL_STR("vinimos");
}
if (slot == 4) {
return EL_STR("vinisteis");
}
return EL_STR("vinieron");
}
if (str_eq(verb, EL_STR("decir"))) {
if (slot == 0) {
return EL_STR("dije");
}
if (slot == 1) {
return EL_STR("dijiste");
}
if (slot == 2) {
return EL_STR("dijo");
}
if (slot == 3) {
return EL_STR("dijimos");
}
if (slot == 4) {
return EL_STR("dijisteis");
}
return EL_STR("dijeron");
}
if (str_eq(verb, EL_STR("haber"))) {
if (slot == 0) {
return EL_STR("hube");
}
if (slot == 1) {
return EL_STR("hubiste");
}
if (slot == 2) {
return EL_STR("hubo");
}
if (slot == 3) {
return EL_STR("hubimos");
}
if (slot == 4) {
return EL_STR("hubisteis");
}
return EL_STR("hubieron");
}
if (str_eq(verb, EL_STR("ver"))) {
if (slot == 0) {
return EL_STR("vi");
}
if (slot == 1) {
return EL_STR("viste");
}
if (slot == 2) {
return EL_STR("vio");
}
if (slot == 3) {
return EL_STR("vimos");
}
if (slot == 4) {
return EL_STR("visteis");
}
return EL_STR("vieron");
}
return EL_STR("");
return 0;
}
el_val_t es_irregular_imperfect(el_val_t verb, el_val_t person, el_val_t number) {
el_val_t slot = es_slot(person, number);
if (str_eq(verb, EL_STR("ser"))) {
if (slot == 0) {
return EL_STR("era");
}
if (slot == 1) {
return EL_STR("eras");
}
if (slot == 2) {
return EL_STR("era");
}
if (slot == 3) {
return EL_STR("\xc3\xa9ramos");
}
if (slot == 4) {
return EL_STR("erais");
}
return EL_STR("eran");
}
if (str_eq(verb, EL_STR("ir"))) {
if (slot == 0) {
return EL_STR("iba");
}
if (slot == 1) {
return EL_STR("ibas");
}
if (slot == 2) {
return EL_STR("iba");
}
if (slot == 3) {
return EL_STR("\xc3\xad""bamos");
}
if (slot == 4) {
return EL_STR("ibais");
}
return EL_STR("iban");
}
if (str_eq(verb, EL_STR("ver"))) {
if (slot == 0) {
return EL_STR("ve\xc3\xad""a");
}
if (slot == 1) {
return EL_STR("ve\xc3\xad""as");
}
if (slot == 2) {
return EL_STR("ve\xc3\xad""a");
}
if (slot == 3) {
return EL_STR("ve\xc3\xad""amos");
}
if (slot == 4) {
return EL_STR("ve\xc3\xad""ais");
}
return EL_STR("ve\xc3\xad""an");
}
return EL_STR("");
return 0;
}
el_val_t es_regular_present(el_val_t stem, el_val_t vclass, el_val_t slot) {
if (str_eq(vclass, EL_STR("ar"))) {
if (slot == 0) {
return el_str_concat(stem, EL_STR("o"));
}
if (slot == 1) {
return el_str_concat(stem, EL_STR("as"));
}
if (slot == 2) {
return el_str_concat(stem, EL_STR("a"));
}
if (slot == 3) {
return el_str_concat(stem, EL_STR("amos"));
}
if (slot == 4) {
return el_str_concat(stem, EL_STR("\xc3\xa1is"));
}
return el_str_concat(stem, EL_STR("an"));
}
if (str_eq(vclass, EL_STR("er"))) {
if (slot == 0) {
return el_str_concat(stem, EL_STR("o"));
}
if (slot == 1) {
return el_str_concat(stem, EL_STR("es"));
}
if (slot == 2) {
return el_str_concat(stem, EL_STR("e"));
}
if (slot == 3) {
return el_str_concat(stem, EL_STR("emos"));
}
if (slot == 4) {
return el_str_concat(stem, EL_STR("\xc3\xa9is"));
}
return el_str_concat(stem, EL_STR("en"));
}
if (slot == 0) {
return el_str_concat(stem, EL_STR("o"));
}
if (slot == 1) {
return el_str_concat(stem, EL_STR("es"));
}
if (slot == 2) {
return el_str_concat(stem, EL_STR("e"));
}
if (slot == 3) {
return el_str_concat(stem, EL_STR("imos"));
}
if (slot == 4) {
return el_str_concat(stem, EL_STR("\xc3\xads"));
}
return el_str_concat(stem, EL_STR("en"));
return 0;
}
el_val_t es_regular_preterite(el_val_t stem, el_val_t vclass, el_val_t slot) {
if (str_eq(vclass, EL_STR("ar"))) {
if (slot == 0) {
return el_str_concat(stem, EL_STR("\xc3\xa9"));
}
if (slot == 1) {
return el_str_concat(stem, EL_STR("aste"));
}
if (slot == 2) {
return el_str_concat(stem, EL_STR("\xc3\xb3"));
}
if (slot == 3) {
return el_str_concat(stem, EL_STR("amos"));
}
if (slot == 4) {
return el_str_concat(stem, EL_STR("asteis"));
}
return el_str_concat(stem, EL_STR("aron"));
}
if (slot == 0) {
return el_str_concat(stem, EL_STR("\xc3\xad"));
}
if (slot == 1) {
return el_str_concat(stem, EL_STR("iste"));
}
if (slot == 2) {
return el_str_concat(stem, EL_STR("i\xc3\xb3"));
}
if (slot == 3) {
return el_str_concat(stem, EL_STR("imos"));
}
if (slot == 4) {
return el_str_concat(stem, EL_STR("isteis"));
}
return el_str_concat(stem, EL_STR("ieron"));
return 0;
}
el_val_t es_regular_future(el_val_t base, el_val_t slot) {
if (slot == 0) {
return el_str_concat(base, EL_STR("\xc3\xa9"));
}
if (slot == 1) {
return el_str_concat(base, EL_STR("\xc3\xa1s"));
}
if (slot == 2) {
return el_str_concat(base, EL_STR("\xc3\xa1"));
}
if (slot == 3) {
return el_str_concat(base, EL_STR("emos"));
}
if (slot == 4) {
return el_str_concat(base, EL_STR("\xc3\xa9is"));
}
return el_str_concat(base, EL_STR("\xc3\xa1n"));
return 0;
}
el_val_t es_irregular_future_stem(el_val_t verb) {
if (str_eq(verb, EL_STR("tener"))) {
return EL_STR("tendr");
}
if (str_eq(verb, EL_STR("hacer"))) {
return EL_STR("har");
}
if (str_eq(verb, EL_STR("poder"))) {
return EL_STR("podr");
}
if (str_eq(verb, EL_STR("querer"))) {
return EL_STR("querr");
}
if (str_eq(verb, EL_STR("venir"))) {
return EL_STR("vendr");
}
if (str_eq(verb, EL_STR("decir"))) {
return EL_STR("dir");
}
if (str_eq(verb, EL_STR("haber"))) {
return EL_STR("habr");
}
if (str_eq(verb, EL_STR("saber"))) {
return EL_STR("sabr");
}
if (str_eq(verb, EL_STR("salir"))) {
return EL_STR("saldr");
}
if (str_eq(verb, EL_STR("poner"))) {
return EL_STR("pondr");
}
return EL_STR("");
return 0;
}
el_val_t es_regular_imperfect(el_val_t stem, el_val_t vclass, el_val_t slot) {
if (str_eq(vclass, EL_STR("ar"))) {
if (slot == 0) {
return el_str_concat(stem, EL_STR("aba"));
}
if (slot == 1) {
return el_str_concat(stem, EL_STR("abas"));
}
if (slot == 2) {
return el_str_concat(stem, EL_STR("aba"));
}
if (slot == 3) {
return el_str_concat(stem, EL_STR("\xc3\xa1""bamos"));
}
if (slot == 4) {
return el_str_concat(stem, EL_STR("abais"));
}
return el_str_concat(stem, EL_STR("aban"));
}
if (slot == 0) {
return el_str_concat(stem, EL_STR("\xc3\xad""a"));
}
if (slot == 1) {
return el_str_concat(stem, EL_STR("\xc3\xad""as"));
}
if (slot == 2) {
return el_str_concat(stem, EL_STR("\xc3\xad""a"));
}
if (slot == 3) {
return el_str_concat(stem, EL_STR("\xc3\xad""amos"));
}
if (slot == 4) {
return el_str_concat(stem, EL_STR("\xc3\xad""ais"));
}
return el_str_concat(stem, EL_STR("\xc3\xad""an"));
return 0;
}
el_val_t es_conjugate(el_val_t verb, el_val_t tense, el_val_t person, el_val_t number) {
el_val_t slot = es_slot(person, number);
if (str_eq(tense, EL_STR("present"))) {
el_val_t irreg = es_irregular_present(verb, person, number);
if (!str_eq(irreg, EL_STR(""))) {
return irreg;
}
el_val_t vclass = es_verb_class(verb);
el_val_t stem = es_stem(verb);
return es_regular_present(stem, vclass, slot);
}
if (str_eq(tense, EL_STR("past"))) {
el_val_t irreg = es_irregular_preterite(verb, person, number);
if (!str_eq(irreg, EL_STR(""))) {
return irreg;
}
el_val_t vclass = es_verb_class(verb);
el_val_t stem = es_stem(verb);
return es_regular_preterite(stem, vclass, slot);
}
if (str_eq(tense, EL_STR("future"))) {
el_val_t irreg_stem = es_irregular_future_stem(verb);
if (!str_eq(irreg_stem, EL_STR(""))) {
return es_regular_future(irreg_stem, slot);
}
return es_regular_future(verb, slot);
}
if (str_eq(tense, EL_STR("imperfect"))) {
el_val_t irreg = es_irregular_imperfect(verb, person, number);
if (!str_eq(irreg, EL_STR(""))) {
return irreg;
}
el_val_t vclass = es_verb_class(verb);
el_val_t stem = es_stem(verb);
return es_regular_imperfect(stem, vclass, slot);
}
return verb;
return 0;
}
el_val_t es_gender(el_val_t noun) {
if (es_str_ends(noun, EL_STR("i\xc3\xb3n"))) {
return EL_STR("f");
}
if (es_str_ends(noun, EL_STR("dad"))) {
return EL_STR("f");
}
if (es_str_ends(noun, EL_STR("tad"))) {
return EL_STR("f");
}
if (es_str_ends(noun, EL_STR("umbre"))) {
return EL_STR("f");
}
if (es_str_ends(noun, EL_STR("sis"))) {
return EL_STR("f");
}
if (es_str_ends(noun, EL_STR("ema"))) {
return EL_STR("m");
}
if (es_str_ends(noun, EL_STR("ama"))) {
return EL_STR("m");
}
if (es_str_ends(noun, EL_STR("aje"))) {
return EL_STR("m");
}
if (es_str_ends(noun, EL_STR("or"))) {
return EL_STR("m");
}
if (es_str_ends(noun, EL_STR("o"))) {
return EL_STR("m");
}
if (es_str_ends(noun, EL_STR("a"))) {
return EL_STR("f");
}
return EL_STR("unknown");
return 0;
}
el_val_t es_invariant_plural(el_val_t noun) {
if (str_eq(noun, EL_STR("lunes"))) {
return EL_STR("lunes");
}
if (str_eq(noun, EL_STR("martes"))) {
return EL_STR("martes");
}
if (str_eq(noun, EL_STR("mi\xc3\xa9rcoles"))) {
return EL_STR("mi\xc3\xa9rcoles");
}
if (str_eq(noun, EL_STR("jueves"))) {
return EL_STR("jueves");
}
if (str_eq(noun, EL_STR("viernes"))) {
return EL_STR("viernes");
}
if (str_eq(noun, EL_STR("crisis"))) {
return EL_STR("crisis");
}
if (str_eq(noun, EL_STR("tesis"))) {
return EL_STR("tesis");
}
if (str_eq(noun, EL_STR("an\xc3\xa1lisis"))) {
return EL_STR("an\xc3\xa1lisis");
}
if (str_eq(noun, EL_STR("dosis"))) {
return EL_STR("dosis");
}
if (str_eq(noun, EL_STR("virus"))) {
return EL_STR("virus");
}
return EL_STR("");
return 0;
}
el_val_t es_pluralize(el_val_t noun) {
el_val_t inv = es_invariant_plural(noun);
if (!str_eq(inv, EL_STR(""))) {
return inv;
}
el_val_t last = es_str_last_char(noun);
if (str_eq(last, EL_STR("z"))) {
return el_str_concat(es_str_drop_last(noun, 1), EL_STR("ces"));
}
if (str_eq(last, EL_STR("a"))) {
return el_str_concat(noun, EL_STR("s"));
}
if (str_eq(last, EL_STR("e"))) {
return el_str_concat(noun, EL_STR("s"));
}
if (str_eq(last, EL_STR("i"))) {
return el_str_concat(noun, EL_STR("s"));
}
if (str_eq(last, EL_STR("o"))) {
return el_str_concat(noun, EL_STR("s"));
}
if (str_eq(last, EL_STR("u"))) {
return el_str_concat(noun, EL_STR("s"));
}
return el_str_concat(noun, EL_STR("es"));
return 0;
}
el_val_t es_starts_with_stressed_a(el_val_t noun) {
el_val_t n = str_len(noun);
if (n == 0) {
return 0;
}
el_val_t c0 = str_slice(noun, 0, 1);
if (str_eq(c0, EL_STR("a"))) {
return 1;
}
if (n >= 2) {
el_val_t c1 = str_slice(noun, 1, 2);
if (str_eq(c0, EL_STR("h"))) {
if (str_eq(c1, EL_STR("a"))) {
return 1;
}
}
}
return 0;
return 0;
}
el_val_t es_agree_article(el_val_t noun, el_val_t definite, el_val_t number) {
el_val_t gender = es_gender(noun);
el_val_t is_plural = str_eq(number, EL_STR("plural"));
el_val_t is_def = str_eq(definite, EL_STR("true"));
if (is_def) {
if (is_plural) {
if (str_eq(gender, EL_STR("f"))) {
return EL_STR("las");
}
return EL_STR("los");
}
if (str_eq(gender, EL_STR("f"))) {
if (es_starts_with_stressed_a(noun)) {
return EL_STR("el");
}
return EL_STR("la");
}
return EL_STR("el");
}
if (is_plural) {
if (str_eq(gender, EL_STR("f"))) {
return EL_STR("unas");
}
return EL_STR("unos");
}
if (str_eq(gender, EL_STR("f"))) {
return EL_STR("una");
}
return EL_STR("un");
return 0;
}