aboutsummaryrefslogtreecommitdiff
path: root/src/ellinika/aorist.c
blob: 995fce8c134f0285e55ce707f22f2eec7d27a993 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
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;
}

		
		

Return to:

Send suggestions and report system problems to the System administrator.