Files
neuron/dist/morphology-fro.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

812 lines
19 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 fro_str_ends(el_val_t s, el_val_t suf);
el_val_t fro_drop(el_val_t s, el_val_t n);
el_val_t fro_slot(el_val_t person, el_val_t number);
el_val_t fro_map_canonical(el_val_t verb);
el_val_t fro_estre_present(el_val_t slot);
el_val_t fro_estre_past(el_val_t slot);
el_val_t fro_estre_future(el_val_t slot);
el_val_t fro_avoir_present(el_val_t slot);
el_val_t fro_avoir_past(el_val_t slot);
el_val_t fro_avoir_future(el_val_t slot);
el_val_t fro_aler_present(el_val_t slot);
el_val_t fro_aler_past(el_val_t slot);
el_val_t fro_aler_future(el_val_t slot);
el_val_t fro_venir_present(el_val_t slot);
el_val_t fro_venir_past(el_val_t slot);
el_val_t fro_venir_future(el_val_t slot);
el_val_t fro_faire_present(el_val_t slot);
el_val_t fro_faire_past(el_val_t slot);
el_val_t fro_faire_future(el_val_t slot);
el_val_t fro_verb_class(el_val_t verb);
el_val_t fro_verb_stem(el_val_t verb, el_val_t vclass);
el_val_t fro_conj1_present(el_val_t stem, el_val_t slot);
el_val_t fro_conj1_past(el_val_t stem, el_val_t slot);
el_val_t fro_conj1_future(el_val_t verb, el_val_t slot);
el_val_t fro_conj2_present(el_val_t stem, el_val_t slot);
el_val_t fro_conj2_past(el_val_t stem, el_val_t slot);
el_val_t fro_conj2_future(el_val_t verb, el_val_t slot);
el_val_t fro_conj3_present(el_val_t stem, el_val_t slot);
el_val_t fro_conj3_past(el_val_t stem, el_val_t slot);
el_val_t fro_conj3_future(el_val_t verb, el_val_t slot);
el_val_t fro_conjugate(el_val_t verb, el_val_t tense, el_val_t person, el_val_t number);
el_val_t fro_gender(el_val_t noun);
el_val_t fro_decline_masc(el_val_t noun, el_val_t gram_case, el_val_t number);
el_val_t fro_decline_fem(el_val_t noun, el_val_t number);
el_val_t fro_decline(el_val_t noun, el_val_t gram_case, el_val_t number);
el_val_t fro_article(el_val_t gender, el_val_t gram_case, el_val_t number);
el_val_t fro_noun_phrase(el_val_t noun, el_val_t gram_case, el_val_t number, el_val_t definite);
el_val_t fro_str_ends(el_val_t s, el_val_t suf) {
return str_ends_with(s, suf);
return 0;
}
el_val_t fro_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 fro_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 fro_map_canonical(el_val_t verb) {
if (str_eq(verb, EL_STR("be"))) {
return EL_STR("estre");
}
if (str_eq(verb, EL_STR("have"))) {
return EL_STR("avoir");
}
if (str_eq(verb, EL_STR("go"))) {
return EL_STR("aler");
}
if (str_eq(verb, EL_STR("come"))) {
return EL_STR("venir");
}
if (str_eq(verb, EL_STR("do"))) {
return EL_STR("faire");
}
if (str_eq(verb, EL_STR("make"))) {
return EL_STR("faire");
}
if (str_eq(verb, EL_STR("say"))) {
return EL_STR("dire");
}
if (str_eq(verb, EL_STR("see"))) {
return EL_STR("veoir");
}
if (str_eq(verb, EL_STR("want"))) {
return EL_STR("vouloir");
}
if (str_eq(verb, EL_STR("can"))) {
return EL_STR("pooir");
}
return verb;
return 0;
}
el_val_t fro_estre_present(el_val_t slot) {
if (slot == 0) {
return EL_STR("sui");
}
if (slot == 1) {
return EL_STR("es");
}
if (slot == 2) {
return EL_STR("est");
}
if (slot == 3) {
return EL_STR("somes");
}
if (slot == 4) {
return EL_STR("estes");
}
return EL_STR("sont");
return 0;
}
el_val_t fro_estre_past(el_val_t slot) {
if (slot == 0) {
return EL_STR("fui");
}
if (slot == 1) {
return EL_STR("fus");
}
if (slot == 2) {
return EL_STR("fu");
}
if (slot == 3) {
return EL_STR("fumes");
}
if (slot == 4) {
return EL_STR("fustes");
}
return EL_STR("furent");
return 0;
}
el_val_t fro_estre_future(el_val_t slot) {
if (slot == 0) {
return EL_STR("esterai");
}
if (slot == 1) {
return EL_STR("esteras");
}
if (slot == 2) {
return EL_STR("estera");
}
if (slot == 3) {
return EL_STR("esterons");
}
if (slot == 4) {
return EL_STR("esterez");
}
return EL_STR("esteront");
return 0;
}
el_val_t fro_avoir_present(el_val_t slot) {
if (slot == 0) {
return EL_STR("ai");
}
if (slot == 1) {
return EL_STR("as");
}
if (slot == 2) {
return EL_STR("a");
}
if (slot == 3) {
return EL_STR("avons");
}
if (slot == 4) {
return EL_STR("avez");
}
return EL_STR("ont");
return 0;
}
el_val_t fro_avoir_past(el_val_t slot) {
if (slot == 0) {
return EL_STR("oi");
}
if (slot == 1) {
return EL_STR("os");
}
if (slot == 2) {
return EL_STR("ot");
}
if (slot == 3) {
return EL_STR("eumes");
}
if (slot == 4) {
return EL_STR("eustes");
}
return EL_STR("orent");
return 0;
}
el_val_t fro_avoir_future(el_val_t slot) {
if (slot == 0) {
return EL_STR("avrai");
}
if (slot == 1) {
return EL_STR("avras");
}
if (slot == 2) {
return EL_STR("avra");
}
if (slot == 3) {
return EL_STR("avrons");
}
if (slot == 4) {
return EL_STR("avrez");
}
return EL_STR("avront");
return 0;
}
el_val_t fro_aler_present(el_val_t slot) {
if (slot == 0) {
return EL_STR("vois");
}
if (slot == 1) {
return EL_STR("vas");
}
if (slot == 2) {
return EL_STR("va");
}
if (slot == 3) {
return EL_STR("alons");
}
if (slot == 4) {
return EL_STR("alez");
}
return EL_STR("vont");
return 0;
}
el_val_t fro_aler_past(el_val_t slot) {
if (slot == 0) {
return EL_STR("alai");
}
if (slot == 1) {
return EL_STR("alas");
}
if (slot == 2) {
return EL_STR("ala");
}
if (slot == 3) {
return EL_STR("alames");
}
if (slot == 4) {
return EL_STR("alastes");
}
return EL_STR("alerent");
return 0;
}
el_val_t fro_aler_future(el_val_t slot) {
if (slot == 0) {
return EL_STR("irai");
}
if (slot == 1) {
return EL_STR("iras");
}
if (slot == 2) {
return EL_STR("ira");
}
if (slot == 3) {
return EL_STR("irons");
}
if (slot == 4) {
return EL_STR("irez");
}
return EL_STR("iront");
return 0;
}
el_val_t fro_venir_present(el_val_t slot) {
if (slot == 0) {
return EL_STR("vieng");
}
if (slot == 1) {
return EL_STR("viens");
}
if (slot == 2) {
return EL_STR("vient");
}
if (slot == 3) {
return EL_STR("venons");
}
if (slot == 4) {
return EL_STR("venez");
}
return EL_STR("vienent");
return 0;
}
el_val_t fro_venir_past(el_val_t slot) {
if (slot == 0) {
return EL_STR("ving");
}
if (slot == 1) {
return EL_STR("vins");
}
if (slot == 2) {
return EL_STR("vint");
}
if (slot == 3) {
return EL_STR("vinsmes");
}
if (slot == 4) {
return EL_STR("vinstes");
}
return EL_STR("vindrent");
return 0;
}
el_val_t fro_venir_future(el_val_t slot) {
if (slot == 0) {
return EL_STR("venrai");
}
if (slot == 1) {
return EL_STR("venras");
}
if (slot == 2) {
return EL_STR("venra");
}
if (slot == 3) {
return EL_STR("venrons");
}
if (slot == 4) {
return EL_STR("venrez");
}
return EL_STR("venront");
return 0;
}
el_val_t fro_faire_present(el_val_t slot) {
if (slot == 0) {
return EL_STR("faz");
}
if (slot == 1) {
return EL_STR("fais");
}
if (slot == 2) {
return EL_STR("fait");
}
if (slot == 3) {
return EL_STR("faisons");
}
if (slot == 4) {
return EL_STR("faites");
}
return EL_STR("font");
return 0;
}
el_val_t fro_faire_past(el_val_t slot) {
if (slot == 0) {
return EL_STR("fis");
}
if (slot == 1) {
return EL_STR("fis");
}
if (slot == 2) {
return EL_STR("fist");
}
if (slot == 3) {
return EL_STR("fimes");
}
if (slot == 4) {
return EL_STR("fistes");
}
return EL_STR("firent");
return 0;
}
el_val_t fro_faire_future(el_val_t slot) {
if (slot == 0) {
return EL_STR("ferai");
}
if (slot == 1) {
return EL_STR("feras");
}
if (slot == 2) {
return EL_STR("fera");
}
if (slot == 3) {
return EL_STR("ferons");
}
if (slot == 4) {
return EL_STR("ferez");
}
return EL_STR("feront");
return 0;
}
el_val_t fro_verb_class(el_val_t verb) {
if (fro_str_ends(verb, EL_STR("er"))) {
return EL_STR("1");
}
if (fro_str_ends(verb, EL_STR("ir"))) {
return EL_STR("2");
}
if (fro_str_ends(verb, EL_STR("re"))) {
return EL_STR("3");
}
return EL_STR("1");
return 0;
}
el_val_t fro_verb_stem(el_val_t verb, el_val_t vclass) {
return fro_drop(verb, 2);
return 0;
}
el_val_t fro_conj1_present(el_val_t stem, el_val_t slot) {
if (slot == 0) {
return el_str_concat(stem, EL_STR("e"));
}
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("ons"));
}
if (slot == 4) {
return el_str_concat(stem, EL_STR("ez"));
}
return el_str_concat(stem, EL_STR("ent"));
return 0;
}
el_val_t fro_conj1_past(el_val_t stem, el_val_t slot) {
if (slot == 0) {
return el_str_concat(stem, EL_STR("ai"));
}
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("ames"));
}
if (slot == 4) {
return el_str_concat(stem, EL_STR("astes"));
}
return el_str_concat(stem, EL_STR("erent"));
return 0;
}
el_val_t fro_conj1_future(el_val_t verb, el_val_t slot) {
el_val_t base = fro_drop(verb, 1);
if (slot == 0) {
return el_str_concat(base, EL_STR("rai"));
}
if (slot == 1) {
return el_str_concat(base, EL_STR("ras"));
}
if (slot == 2) {
return el_str_concat(base, EL_STR("ra"));
}
if (slot == 3) {
return el_str_concat(base, EL_STR("rons"));
}
if (slot == 4) {
return el_str_concat(base, EL_STR("rez"));
}
return el_str_concat(base, EL_STR("ront"));
return 0;
}
el_val_t fro_conj2_present(el_val_t stem, el_val_t slot) {
if (slot == 0) {
return el_str_concat(stem, EL_STR("is"));
}
if (slot == 1) {
return el_str_concat(stem, EL_STR("is"));
}
if (slot == 2) {
return el_str_concat(stem, EL_STR("it"));
}
if (slot == 3) {
return el_str_concat(stem, EL_STR("issons"));
}
if (slot == 4) {
return el_str_concat(stem, EL_STR("issiez"));
}
return el_str_concat(stem, EL_STR("issent"));
return 0;
}
el_val_t fro_conj2_past(el_val_t stem, el_val_t slot) {
if (slot == 0) {
return el_str_concat(stem, EL_STR("is"));
}
if (slot == 1) {
return el_str_concat(stem, EL_STR("is"));
}
if (slot == 2) {
return el_str_concat(stem, EL_STR("it"));
}
if (slot == 3) {
return el_str_concat(stem, EL_STR("imes"));
}
if (slot == 4) {
return el_str_concat(stem, EL_STR("istes"));
}
return el_str_concat(stem, EL_STR("irent"));
return 0;
}
el_val_t fro_conj2_future(el_val_t verb, el_val_t slot) {
el_val_t base = fro_drop(verb, 1);
if (slot == 0) {
return el_str_concat(base, EL_STR("rai"));
}
if (slot == 1) {
return el_str_concat(base, EL_STR("ras"));
}
if (slot == 2) {
return el_str_concat(base, EL_STR("ra"));
}
if (slot == 3) {
return el_str_concat(base, EL_STR("rons"));
}
if (slot == 4) {
return el_str_concat(base, EL_STR("rez"));
}
return el_str_concat(base, EL_STR("ront"));
return 0;
}
el_val_t fro_conj3_present(el_val_t stem, el_val_t slot) {
if (slot == 0) {
return stem;
}
if (slot == 1) {
return el_str_concat(stem, EL_STR("s"));
}
if (slot == 2) {
return el_str_concat(stem, EL_STR("t"));
}
if (slot == 3) {
return el_str_concat(stem, EL_STR("ons"));
}
if (slot == 4) {
return el_str_concat(stem, EL_STR("ez"));
}
return el_str_concat(stem, EL_STR("ent"));
return 0;
}
el_val_t fro_conj3_past(el_val_t stem, el_val_t slot) {
if (slot == 0) {
return el_str_concat(stem, EL_STR("is"));
}
if (slot == 1) {
return el_str_concat(stem, EL_STR("is"));
}
if (slot == 2) {
return el_str_concat(stem, EL_STR("it"));
}
if (slot == 3) {
return el_str_concat(stem, EL_STR("imes"));
}
if (slot == 4) {
return el_str_concat(stem, EL_STR("istes"));
}
return el_str_concat(stem, EL_STR("irent"));
return 0;
}
el_val_t fro_conj3_future(el_val_t verb, el_val_t slot) {
el_val_t base = fro_drop(verb, 2);
if (slot == 0) {
return el_str_concat(base, EL_STR("rai"));
}
if (slot == 1) {
return el_str_concat(base, EL_STR("ras"));
}
if (slot == 2) {
return el_str_concat(base, EL_STR("ra"));
}
if (slot == 3) {
return el_str_concat(base, EL_STR("rons"));
}
if (slot == 4) {
return el_str_concat(base, EL_STR("rez"));
}
return el_str_concat(base, EL_STR("ront"));
return 0;
}
el_val_t fro_conjugate(el_val_t verb, el_val_t tense, el_val_t person, el_val_t number) {
el_val_t v = fro_map_canonical(verb);
el_val_t slot = fro_slot(person, number);
if (str_eq(v, EL_STR("estre"))) {
if (str_eq(tense, EL_STR("present"))) {
return fro_estre_present(slot);
}
if (str_eq(tense, EL_STR("past"))) {
return fro_estre_past(slot);
}
if (str_eq(tense, EL_STR("future"))) {
return fro_estre_future(slot);
}
return v;
}
if (str_eq(v, EL_STR("avoir"))) {
if (str_eq(tense, EL_STR("present"))) {
return fro_avoir_present(slot);
}
if (str_eq(tense, EL_STR("past"))) {
return fro_avoir_past(slot);
}
if (str_eq(tense, EL_STR("future"))) {
return fro_avoir_future(slot);
}
return v;
}
if (str_eq(v, EL_STR("aler"))) {
if (str_eq(tense, EL_STR("present"))) {
return fro_aler_present(slot);
}
if (str_eq(tense, EL_STR("past"))) {
return fro_aler_past(slot);
}
if (str_eq(tense, EL_STR("future"))) {
return fro_aler_future(slot);
}
return v;
}
if (str_eq(v, EL_STR("venir"))) {
if (str_eq(tense, EL_STR("present"))) {
return fro_venir_present(slot);
}
if (str_eq(tense, EL_STR("past"))) {
return fro_venir_past(slot);
}
if (str_eq(tense, EL_STR("future"))) {
return fro_venir_future(slot);
}
return v;
}
if (str_eq(v, EL_STR("faire"))) {
if (str_eq(tense, EL_STR("present"))) {
return fro_faire_present(slot);
}
if (str_eq(tense, EL_STR("past"))) {
return fro_faire_past(slot);
}
if (str_eq(tense, EL_STR("future"))) {
return fro_faire_future(slot);
}
return v;
}
el_val_t vclass = fro_verb_class(v);
el_val_t stem = fro_verb_stem(v, vclass);
if (str_eq(vclass, EL_STR("1"))) {
if (str_eq(tense, EL_STR("present"))) {
return fro_conj1_present(stem, slot);
}
if (str_eq(tense, EL_STR("past"))) {
return fro_conj1_past(stem, slot);
}
if (str_eq(tense, EL_STR("future"))) {
return fro_conj1_future(v, slot);
}
return v;
}
if (str_eq(vclass, EL_STR("2"))) {
if (str_eq(tense, EL_STR("present"))) {
return fro_conj2_present(stem, slot);
}
if (str_eq(tense, EL_STR("past"))) {
return fro_conj2_past(stem, slot);
}
if (str_eq(tense, EL_STR("future"))) {
return fro_conj2_future(v, slot);
}
return v;
}
if (str_eq(vclass, EL_STR("3"))) {
if (str_eq(tense, EL_STR("present"))) {
return fro_conj3_present(stem, slot);
}
if (str_eq(tense, EL_STR("past"))) {
return fro_conj3_past(stem, slot);
}
if (str_eq(tense, EL_STR("future"))) {
return fro_conj3_future(v, slot);
}
return v;
}
return v;
return 0;
}
el_val_t fro_gender(el_val_t noun) {
if (fro_str_ends(noun, EL_STR("e"))) {
return EL_STR("fem");
}
return EL_STR("masc");
return 0;
}
el_val_t fro_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("s"));
}
return noun;
}
if (str_eq(gram_case, EL_STR("nominative"))) {
return noun;
}
return el_str_concat(noun, EL_STR("s"));
return 0;
}
el_val_t fro_decline_fem(el_val_t noun, el_val_t number) {
if (str_eq(number, EL_STR("singular"))) {
return noun;
}
return el_str_concat(noun, EL_STR("s"));
return 0;
}
el_val_t fro_decline(el_val_t noun, el_val_t gram_case, el_val_t number) {
el_val_t gender = fro_gender(noun);
if (str_eq(gender, EL_STR("masc"))) {
return fro_decline_masc(noun, gram_case, number);
}
return fro_decline_fem(noun, number);
return 0;
}
el_val_t fro_article(el_val_t gender, el_val_t gram_case, el_val_t number) {
if (str_eq(gender, EL_STR("masc"))) {
if (str_eq(number, EL_STR("plural"))) {
return EL_STR("les");
}
if (str_eq(gram_case, EL_STR("nominative"))) {
return EL_STR("li");
}
return EL_STR("le");
}
if (str_eq(number, EL_STR("plural"))) {
return EL_STR("les");
}
return EL_STR("la");
return 0;
}
el_val_t fro_noun_phrase(el_val_t noun, el_val_t gram_case, el_val_t number, el_val_t definite) {
el_val_t gender = fro_gender(noun);
el_val_t declined = fro_decline(noun, gram_case, number);
if (str_eq(definite, EL_STR("true"))) {
el_val_t art = fro_article(gender, gram_case, number);
return el_str_concat(el_str_concat(art, EL_STR(" ")), declined);
}
return declined;
return 0;
}