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

642 lines
16 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 akk_str_ends(el_val_t s, el_val_t suf);
el_val_t akk_str_len(el_val_t s);
el_val_t akk_str_drop_last(el_val_t s, el_val_t n);
el_val_t akk_slot(el_val_t person, el_val_t number);
el_val_t akk_slot_g(el_val_t person, el_val_t gender, el_val_t number);
el_val_t akk_copula_present(el_val_t slot);
el_val_t akk_copula_stative(el_val_t slot);
el_val_t akk_is_copula(el_val_t verb);
el_val_t akk_conjugate_copula(el_val_t tense, el_val_t slot);
el_val_t akk_alaku_present(el_val_t slot);
el_val_t akk_alaku_perfect(el_val_t slot);
el_val_t akk_amaru_present(el_val_t slot);
el_val_t akk_amaru_perfect(el_val_t slot);
el_val_t akk_amaru_stative(el_val_t slot);
el_val_t akk_qabu_present(el_val_t slot);
el_val_t akk_qabu_perfect(el_val_t slot);
el_val_t akk_qabu_stative(el_val_t slot);
el_val_t akk_epesu_present(el_val_t slot);
el_val_t akk_epesu_perfect(el_val_t slot);
el_val_t akk_epesu_stative(el_val_t slot);
el_val_t akk_regular_present(el_val_t stem, el_val_t slot);
el_val_t akk_regular_perfect(el_val_t stem, el_val_t slot);
el_val_t akk_regular_stative(el_val_t stem, el_val_t slot);
el_val_t akk_known_verb(el_val_t verb, el_val_t tense, el_val_t slot);
el_val_t akk_conjugate(el_val_t verb, el_val_t tense, el_val_t person, el_val_t number);
el_val_t akk_strip_nom(el_val_t noun);
el_val_t akk_is_fem(el_val_t noun);
el_val_t akk_decline(el_val_t noun, el_val_t gram_case, el_val_t number);
el_val_t akk_noun_phrase(el_val_t noun, el_val_t gram_case, el_val_t number, el_val_t definite);
el_val_t akk_map_canonical(el_val_t verb);
el_val_t akk_str_ends(el_val_t s, el_val_t suf) {
return str_ends_with(s, suf);
return 0;
}
el_val_t akk_str_len(el_val_t s) {
return str_len(s);
return 0;
}
el_val_t akk_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 akk_slot(el_val_t person, el_val_t number) {
if (str_eq(person, EL_STR("first"))) {
if (str_eq(number, EL_STR("plural"))) {
return 4;
}
return 0;
}
if (str_eq(person, EL_STR("second"))) {
return 1;
}
if (str_eq(number, EL_STR("plural"))) {
return 5;
}
return 2;
return 0;
}
el_val_t akk_slot_g(el_val_t person, el_val_t gender, el_val_t number) {
el_val_t base = akk_slot(person, number);
if (str_eq(person, EL_STR("third"))) {
if (str_eq(number, EL_STR("singular"))) {
if (str_eq(gender, EL_STR("f"))) {
return 3;
}
}
}
return base;
return 0;
}
el_val_t akk_copula_present(el_val_t slot) {
if (slot == 0) {
return EL_STR("aba\xc5\xa1\xc5\xa1i");
}
if (slot == 1) {
return EL_STR("taba\xc5\xa1\xc5\xa1i");
}
if (slot == 2) {
return EL_STR("iba\xc5\xa1\xc5\xa1i");
}
if (slot == 3) {
return EL_STR("iba\xc5\xa1\xc5\xa1i");
}
if (slot == 4) {
return EL_STR("niba\xc5\xa1\xc5\xa1i");
}
return EL_STR("iba\xc5\xa1\xc5\xa1\xc5\xab");
return 0;
}
el_val_t akk_copula_stative(el_val_t slot) {
if (slot == 0) {
return EL_STR("ba\xc5\xa1\xc4\x81ku");
}
if (slot == 1) {
return EL_STR("ba\xc5\xa1\xc4\x81ta");
}
if (slot == 2) {
return EL_STR("ba\xc5\xa1\xc4\xab");
}
if (slot == 3) {
return EL_STR("ba\xc5\xa1iat");
}
if (slot == 4) {
return EL_STR("ba\xc5\xa1\xc4\x81nu");
}
return EL_STR("ba\xc5\xa1\xc5\xab");
return 0;
}
el_val_t akk_is_copula(el_val_t verb) {
if (str_eq(verb, EL_STR("ba\xc5\xa1\xc3\xbb"))) {
return 1;
}
if (str_eq(verb, EL_STR("bashu"))) {
return 1;
}
if (str_eq(verb, EL_STR("be"))) {
return 1;
}
return 0;
return 0;
}
el_val_t akk_conjugate_copula(el_val_t tense, el_val_t slot) {
if (str_eq(tense, EL_STR("stative"))) {
return akk_copula_stative(slot);
}
return akk_copula_present(slot);
return 0;
}
el_val_t akk_alaku_present(el_val_t slot) {
if (slot == 0) {
return EL_STR("allak");
}
if (slot == 1) {
return EL_STR("tallak");
}
if (slot == 2) {
return EL_STR("illak");
}
if (slot == 3) {
return EL_STR("tallak");
}
if (slot == 4) {
return EL_STR("nillak");
}
return EL_STR("illaku");
return 0;
}
el_val_t akk_alaku_perfect(el_val_t slot) {
if (slot == 0) {
return EL_STR("ittalak");
}
if (slot == 1) {
return EL_STR("tattalak");
}
if (slot == 2) {
return EL_STR("ittalak");
}
if (slot == 3) {
return EL_STR("tattalak");
}
if (slot == 4) {
return EL_STR("nittalak");
}
return EL_STR("ittalku");
return 0;
}
el_val_t akk_amaru_present(el_val_t slot) {
if (slot == 0) {
return EL_STR("ammar");
}
if (slot == 1) {
return EL_STR("tammar");
}
if (slot == 2) {
return EL_STR("immar");
}
if (slot == 3) {
return EL_STR("tammar");
}
if (slot == 4) {
return EL_STR("nimmar");
}
return EL_STR("immaru");
return 0;
}
el_val_t akk_amaru_perfect(el_val_t slot) {
if (slot == 0) {
return EL_STR("amtamar");
}
if (slot == 1) {
return EL_STR("tamtamar");
}
if (slot == 2) {
return EL_STR("imtamar");
}
if (slot == 3) {
return EL_STR("tamtamar");
}
if (slot == 4) {
return EL_STR("nimtamar");
}
return EL_STR("imtamaru");
return 0;
}
el_val_t akk_amaru_stative(el_val_t slot) {
if (slot == 0) {
return EL_STR("amr\xc4\x81ku");
}
if (slot == 1) {
return EL_STR("amr\xc4\x81ta");
}
if (slot == 2) {
return EL_STR("amir");
}
if (slot == 3) {
return EL_STR("amrat");
}
if (slot == 4) {
return EL_STR("amr\xc4\x81nu");
}
return EL_STR("amr\xc5\xab");
return 0;
}
el_val_t akk_qabu_present(el_val_t slot) {
if (slot == 0) {
return EL_STR("aqabbi");
}
if (slot == 1) {
return EL_STR("taqabbi");
}
if (slot == 2) {
return EL_STR("iqabbi");
}
if (slot == 3) {
return EL_STR("taqabbi");
}
if (slot == 4) {
return EL_STR("niqabbi");
}
return EL_STR("iqabb\xc3\xbb");
return 0;
}
el_val_t akk_qabu_perfect(el_val_t slot) {
if (slot == 0) {
return EL_STR("aqtabi");
}
if (slot == 1) {
return EL_STR("taqtabi");
}
if (slot == 2) {
return EL_STR("iqtabi");
}
if (slot == 3) {
return EL_STR("taqtabi");
}
if (slot == 4) {
return EL_STR("niqtabi");
}
return EL_STR("iqtab\xc3\xbb");
return 0;
}
el_val_t akk_qabu_stative(el_val_t slot) {
if (slot == 0) {
return EL_STR("qab\xc4\x81ku");
}
if (slot == 1) {
return EL_STR("qab\xc4\x81ta");
}
if (slot == 2) {
return EL_STR("qabi");
}
if (slot == 3) {
return EL_STR("qabiat");
}
if (slot == 4) {
return EL_STR("qab\xc4\x81nu");
}
return EL_STR("qab\xc3\xbb");
return 0;
}
el_val_t akk_epesu_present(el_val_t slot) {
if (slot == 0) {
return EL_STR("eppu\xc5\xa1");
}
if (slot == 1) {
return EL_STR("teppu\xc5\xa1");
}
if (slot == 2) {
return EL_STR("ieppu\xc5\xa1");
}
if (slot == 3) {
return EL_STR("teppu\xc5\xa1");
}
if (slot == 4) {
return EL_STR("neppu\xc5\xa1");
}
return EL_STR("ieppu\xc5\xa1u");
return 0;
}
el_val_t akk_epesu_perfect(el_val_t slot) {
if (slot == 0) {
return EL_STR("ipte\xc5\xa1u");
}
if (slot == 1) {
return EL_STR("tapte\xc5\xa1u");
}
if (slot == 2) {
return EL_STR("ipte\xc5\xa1u");
}
if (slot == 3) {
return EL_STR("tapte\xc5\xa1u");
}
if (slot == 4) {
return EL_STR("nipte\xc5\xa1u");
}
return EL_STR("ipte\xc5\xa1\xc5\xab");
return 0;
}
el_val_t akk_epesu_stative(el_val_t slot) {
if (slot == 0) {
return EL_STR("ep\xc5\xa1\xc4\x81ku");
}
if (slot == 1) {
return EL_STR("ep\xc5\xa1\xc4\x81ta");
}
if (slot == 2) {
return EL_STR("epu\xc5\xa1");
}
if (slot == 3) {
return EL_STR("ep\xc5\xa1""at");
}
if (slot == 4) {
return EL_STR("ep\xc5\xa1\xc4\x81nu");
}
return EL_STR("ep\xc5\xa1\xc5\xab");
return 0;
}
el_val_t akk_regular_present(el_val_t stem, el_val_t slot) {
if (slot == 0) {
return el_str_concat(EL_STR("a"), stem);
}
if (slot == 1) {
return el_str_concat(EL_STR("ta"), stem);
}
if (slot == 2) {
return el_str_concat(EL_STR("i"), stem);
}
if (slot == 3) {
return el_str_concat(EL_STR("ta"), stem);
}
if (slot == 4) {
return el_str_concat(EL_STR("ni"), stem);
}
return el_str_concat(el_str_concat(EL_STR("i"), stem), EL_STR("u"));
return 0;
}
el_val_t akk_regular_perfect(el_val_t stem, el_val_t slot) {
if (slot == 0) {
return el_str_concat(EL_STR("a"), stem);
}
if (slot == 1) {
return el_str_concat(EL_STR("ta"), stem);
}
if (slot == 2) {
return el_str_concat(EL_STR("i"), stem);
}
if (slot == 3) {
return el_str_concat(EL_STR("ta"), stem);
}
if (slot == 4) {
return el_str_concat(EL_STR("ni"), stem);
}
return el_str_concat(el_str_concat(EL_STR("i"), stem), EL_STR("u"));
return 0;
}
el_val_t akk_regular_stative(el_val_t stem, el_val_t slot) {
if (slot == 0) {
return el_str_concat(stem, EL_STR("\xc4\x81ku"));
}
if (slot == 1) {
return el_str_concat(stem, EL_STR("\xc4\x81ta"));
}
if (slot == 2) {
return stem;
}
if (slot == 3) {
return el_str_concat(stem, EL_STR("at"));
}
if (slot == 4) {
return el_str_concat(stem, EL_STR("\xc4\x81nu"));
}
return el_str_concat(stem, EL_STR("\xc5\xab"));
return 0;
}
el_val_t akk_known_verb(el_val_t verb, el_val_t tense, el_val_t slot) {
if (str_eq(verb, EL_STR("ba\xc5\xa1\xc3\xbb"))) {
return akk_conjugate_copula(tense, slot);
}
if (str_eq(verb, EL_STR("bashu"))) {
return akk_conjugate_copula(tense, slot);
}
if (str_eq(verb, EL_STR("al\xc4\x81ku"))) {
if (str_eq(tense, EL_STR("perfect"))) {
return akk_alaku_perfect(slot);
}
if (str_eq(tense, EL_STR("stative"))) {
return akk_alaku_present(slot);
}
return akk_alaku_present(slot);
}
if (str_eq(verb, EL_STR("alaku"))) {
if (str_eq(tense, EL_STR("perfect"))) {
return akk_alaku_perfect(slot);
}
return akk_alaku_present(slot);
}
if (str_eq(verb, EL_STR("am\xc4\x81ru"))) {
if (str_eq(tense, EL_STR("perfect"))) {
return akk_amaru_perfect(slot);
}
if (str_eq(tense, EL_STR("stative"))) {
return akk_amaru_stative(slot);
}
return akk_amaru_present(slot);
}
if (str_eq(verb, EL_STR("amaru"))) {
if (str_eq(tense, EL_STR("perfect"))) {
return akk_amaru_perfect(slot);
}
if (str_eq(tense, EL_STR("stative"))) {
return akk_amaru_stative(slot);
}
return akk_amaru_present(slot);
}
if (str_eq(verb, EL_STR("qab\xc3\xbb"))) {
if (str_eq(tense, EL_STR("perfect"))) {
return akk_qabu_perfect(slot);
}
if (str_eq(tense, EL_STR("stative"))) {
return akk_qabu_stative(slot);
}
return akk_qabu_present(slot);
}
if (str_eq(verb, EL_STR("qabu"))) {
if (str_eq(tense, EL_STR("perfect"))) {
return akk_qabu_perfect(slot);
}
if (str_eq(tense, EL_STR("stative"))) {
return akk_qabu_stative(slot);
}
return akk_qabu_present(slot);
}
if (str_eq(verb, EL_STR("ep\xc4\x93\xc5\xa1u"))) {
if (str_eq(tense, EL_STR("perfect"))) {
return akk_epesu_perfect(slot);
}
if (str_eq(tense, EL_STR("stative"))) {
return akk_epesu_stative(slot);
}
return akk_epesu_present(slot);
}
if (str_eq(verb, EL_STR("epesu"))) {
if (str_eq(tense, EL_STR("perfect"))) {
return akk_epesu_perfect(slot);
}
if (str_eq(tense, EL_STR("stative"))) {
return akk_epesu_stative(slot);
}
return akk_epesu_present(slot);
}
return EL_STR("");
return 0;
}
el_val_t akk_conjugate(el_val_t verb, el_val_t tense, el_val_t person, el_val_t number) {
el_val_t slot = akk_slot(person, number);
if (akk_is_copula(verb)) {
return akk_conjugate_copula(tense, slot);
}
el_val_t known = akk_known_verb(verb, tense, slot);
if (!str_eq(known, EL_STR(""))) {
return known;
}
return verb;
return 0;
}
el_val_t akk_strip_nom(el_val_t noun) {
if (akk_str_ends(noun, EL_STR("um"))) {
return akk_str_drop_last(noun, 2);
}
if (akk_str_ends(noun, EL_STR("tum"))) {
return akk_str_drop_last(noun, 3);
}
return noun;
return 0;
}
el_val_t akk_is_fem(el_val_t noun) {
if (akk_str_ends(noun, EL_STR("tum"))) {
return 1;
}
if (akk_str_ends(noun, EL_STR("tam"))) {
return 1;
}
if (akk_str_ends(noun, EL_STR("tim"))) {
return 1;
}
return 0;
return 0;
}
el_val_t akk_decline(el_val_t noun, el_val_t gram_case, el_val_t number) {
el_val_t fem = akk_is_fem(noun);
el_val_t stem = akk_strip_nom(noun);
if (str_eq(number, EL_STR("singular"))) {
if (fem) {
if (str_eq(gram_case, EL_STR("nom"))) {
return el_str_concat(stem, EL_STR("tum"));
}
if (str_eq(gram_case, EL_STR("acc"))) {
return el_str_concat(stem, EL_STR("tam"));
}
if (str_eq(gram_case, EL_STR("gen"))) {
return el_str_concat(stem, EL_STR("tim"));
}
return el_str_concat(stem, EL_STR("tum"));
}
if (str_eq(gram_case, EL_STR("nom"))) {
return el_str_concat(stem, EL_STR("um"));
}
if (str_eq(gram_case, EL_STR("acc"))) {
return el_str_concat(stem, EL_STR("am"));
}
if (str_eq(gram_case, EL_STR("gen"))) {
return el_str_concat(stem, EL_STR("im"));
}
return el_str_concat(stem, EL_STR("um"));
}
if (fem) {
if (str_eq(gram_case, EL_STR("nom"))) {
return el_str_concat(stem, EL_STR("\xc4\x81tum"));
}
return el_str_concat(stem, EL_STR("\xc4\x81tim"));
}
if (str_eq(gram_case, EL_STR("nom"))) {
return el_str_concat(stem, EL_STR("\xc5\xabtum"));
}
return el_str_concat(stem, EL_STR("\xc4\x81tim"));
return 0;
}
el_val_t akk_noun_phrase(el_val_t noun, el_val_t gram_case, el_val_t number, el_val_t definite) {
return akk_decline(noun, gram_case, number);
return 0;
}
el_val_t akk_map_canonical(el_val_t verb) {
if (str_eq(verb, EL_STR("be"))) {
return EL_STR("ba\xc5\xa1\xc3\xbb");
}
if (str_eq(verb, EL_STR("go"))) {
return EL_STR("al\xc4\x81ku");
}
if (str_eq(verb, EL_STR("see"))) {
return EL_STR("am\xc4\x81ru");
}
if (str_eq(verb, EL_STR("say"))) {
return EL_STR("qab\xc3\xbb");
}
if (str_eq(verb, EL_STR("speak"))) {
return EL_STR("qab\xc3\xbb");
}
if (str_eq(verb, EL_STR("do"))) {
return EL_STR("ep\xc4\x93\xc5\xa1u");
}
if (str_eq(verb, EL_STR("make"))) {
return EL_STR("ep\xc4\x93\xc5\xa1u");
}
return verb;
return 0;
}