diff options
Diffstat (limited to 'src/ellinika/aorist.c')
-rw-r--r-- | src/ellinika/aorist.c | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/src/ellinika/aorist.c b/src/ellinika/aorist.c new file mode 100644 index 0000000..995fce8 --- /dev/null +++ b/src/ellinika/aorist.c @@ -0,0 +1,73 @@ +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif +#include <errno.h> +#include <stdlib.h> +#include <libguile.h> +#include "utf8.h" +#include "elmorph.h" + +int +elmorph_thema_aoristoy(unsigned *word, size_t len, + unsigned **thema, size_t *tlen) +{ + unsigned ch, *pw; + + switch (word[len-1]) { + case 0x03B6: /* ζ */ + /* FIXME: This can produce ξ as well: αλλάζω => άλλαξα */ + case 0x03B8: /* θ */ + ch = 0x03C3; /* σ */ + break; + + case 0x03B3: /* γ */ + case 0x03C7: /* χ */ + ch = 0x03BE; /* ξ */ + break; + + case 0x03BA: /* κ */ + if (len > 1 && word[len-2] == 0x03C3 /* σκ */) + len--; + ch = 0x03BE; /* ξ */ + break; + + case 0x03BD: /* ν */ + if (len > 1 && word[len-2] == 0x03C7 /* χν */) { + len--; + ch = 0x03BE; /* ξ */ + } else + ch = 0x03C3; /* σ */ + break; + + case 0x03B2: /* β */ + case 0x03C0: /* π */ + case 0x03C6: /* φ */ + ch = 0x03C8; /* ψ */ + break; + + case 0x03CD: /* ύ */ + case 0x03C5: /* υ FIXME: This assumes the word has been deaccentized */ + if (len > 1 && (word[len-2] == 0x03B1 /* αύ */ || + word[len-2] == 0x03B5 /* εύ */)) { + ch = 0x03C8; /* ψ */ + break; + } + + default: + len++; + ch = 0x03C3; /* σ */ + } + + pw = calloc(len, sizeof(pw[0])); + if (!pw) + return -1; + memcpy(pw, word, sizeof(word[0]) * (len - 1)); + pw[len-1] = ch; + + *thema = pw; + *tlen = len; + return 0; +} + + + |