summaryrefslogtreecommitdiff
path: root/examples/foods/MutationsGle.gf
blob: 9ae734a90904577267bd6c976f65ea5392bc6218 (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
90
91
92
resource MutationsGle = open CharactersGle in {
	param Mutation = Unmutated|Lenition1|Lenition1DNTLS|Lenition2|Eclipsis1|Eclipsis2|Eclipsis3|PrefixT|PrefixH;
	
	--Turns a string into a mutation table
	oper mutate : (_ : Str) -> (Mutation => Str) = \str -> table {
		Unmutated => str ;
		Lenition1 => lenition1 str ;
		Lenition1DNTLS => lenition1dntls str ;
		Lenition2 => lenition2 str ;
		Eclipsis1 => eclipsis1 str ;
		Eclipsis2 => eclipsis2 str ;
		Eclipsis3 => eclipsis3 str ;
		PrefixT => prefixT str ;
		PrefixH => prefixH str
	};

	--Performs lenition 1: inserts "h" if the word begins with a lenitable character
	oper lenition1 : Str -> Str = \str -> case str of {
		start@("p"|"b"|"m"|"f"|"t"|"d"|"c"|"g") + rest => start + "h" + rest ;
		start@("P"|"B"|"M"|"F"|"T"|"D"|"C"|"G") + rest => start + "h" + rest ;
		("s"|"S") + ("p"|"t"|"c") + _ => str ; --the sequences "sp", "st", "sc" are never mutated
		start@("s"|"S") + rest => start + "h" + rest ;
		_ => str
	};
	
	--Performs lenition 1 with dentals: same as lenition 1 but leaves "d", "t" and "s" unmutated
	oper lenition1dntls : Str -> Str = \str -> case str of {
		start@("p"|"b"|"m"|"f"|"c"|"g") + rest => start + "h" + rest ;
		start@("P"|"B"|"M"|"F"|"C"|"G") + rest => start + "h" + rest ;
		_ => str
	};

	--Performs lenition 2: same as lenition 1 with dentals but also changes "s" into "ts"
	oper lenition2 : Str -> Str = \str -> case str of {
		start@("p"|"b"|"m"|"f"|"c"|"g") + rest => start + "h" + rest ;
		start@("P"|"B"|"M"|"F"|"C"|"G") + rest => start + "h" + rest ;
		("s"|"S") + ("p"|"t"|"c") + _ => str ; --the sequences "sp", "st", "sc" are never mutated
		start@("s"|"S") + rest => "t" + start + rest ;
		_ => str
	};
	
	--Performs eclisis 1: prefixes something to every word that begins with an ecliptable character
	oper eclipsis1 : Str -> Str = \str -> case str of {
		start@("p"|"P") + rest => "b" + start + rest ;
		start@("b"|"B") + rest => "m" + start + rest ;
		start@("f"|"F") + rest => "bh" + start + rest ;
		start@("c"|"C") + rest => "g" + start + rest ;
		start@("g"|"G") + rest => "n" + start + rest ;
		start@("t"|"T") + rest => "d" + start + rest ;
		start@("d"|"D") + rest => "n" + start + rest ;
		start@(#vowel) + rest => "n-" + start + rest ;
		start@(#vowelCap) + rest => "n" + start + rest ;
		_ => str
	};

	--Performs eclipsis 2: same as eclipsis 1 but leaves "t", "d" and vowels unchanges
	oper eclipsis2 : Str -> Str = \str -> case str of {
		start@("p"|"P") + rest => "b" + start + rest ;
		start@("b"|"B") + rest => "m" + start + rest ;
		start@("f"|"F") + rest => "bh" + start + rest ;
		start@("c"|"C") + rest => "g" + start + rest ;
		start@("g"|"G") + rest => "n" + start + rest ;
		_ => str
	};

	--Performs eclipsis 3: same as eclipsis 2 but also changes "s" to "ts"
	eclipsis3 : Str -> Str = \str -> case str of {
		start@("p"|"P") + rest => "b" + start + rest ;
		start@("b"|"B") + rest => "m" + start + rest ;
		start@("f"|"F") + rest => "bh" + start + rest ;
		start@("c"|"C") + rest => "g" + start + rest ;
		start@("g"|"G") + rest => "n" + start + rest ;
		("s"|"S") + ("p"|"t"|"c") + _ => str ; --the sequences "sp", "st", "sc" are never mutated
		start@("s"|"S") + rest => "t" + start + rest ;
		_ => str
	};

	--Prefixes a "t" to words beginning with a vowel
	oper prefixT : Str -> Str = \str -> case str of {
		start@(#vowel) + rest => "t-" + start + rest ;
		start@(#vowelCap) + rest => "t" + start + rest ;
		_ => str
	};

	--Prefixes a "h" to words beginning with a vowel
	oper prefixH : Str -> Str = \str -> case str of {
		start@(#vowel) + rest => "h" + start + rest ;
		start@(#vowelCap) + rest => "h" + start + rest ;
		_ => str
	};
	
}