summaryrefslogtreecommitdiffabout
path: root/src/ellinika/aorist.c
blob: d713a3dc5ca1a64041d01feb391ba84ed3503ca4 (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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/* This file is part of Ellinika project.
   Copyright (C) 2011 Sergey Poznyakoff

   Ellinika is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3 of the License, or
   (at your option) any later version.

   Ellinika is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
#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.