blob: 280977bd8cc07eaea69c0797e6e51da4f8657a14 (
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
|
(** Module for handling phonological features and segments *)
(* module Feature = struct *)
(** Type representing a phonological feature value *)
type feature_value = Plus | Minus | Zero
(** Type representing a phonological feature *)
type feature =
| Syllabic
| Sonorant
| Consonantal
| Continuant
| DelayedRelease
| Lateral
| Nasal
| Strident
| Voiced
| SpreadGlottis
| ConstrictedGlottis
| Anterior
| Coronal
| Distributed
| Labial
| High
| Low
| Back
| Rounded
| Velaric
| Tense
| Long
| HighTone
| HighReg (*high registry?*)
type feature_spec = feature * feature_value
(** Type representing a feature specification as a (value, feature) pair *)
type segment = feature_spec list
(** Convert a string feature value to the feature_value type *)
let value_of_string = function
| "+" -> Plus
| "-" -> Minus
| "0" -> Zero
| s -> failwith (Printf.sprintf "Invalid feature value: %s" s)
let string_of_feature = function
| "syl" -> Syllabic
| "son" -> Sonorant
| "cons" -> Consonantal
| "cont" -> Continuant
| "delrel" -> DelayedRelease
| "lat" -> Lateral
| "nas" -> Nasal
| "strid" -> Strident
| "voi" -> Voiced
| "sg" -> SpreadGlottis
| "cg" -> ConstrictedGlottis
| "ant" -> Anterior
| "cor" -> Coronal
| "distr" -> Distributed
| "lab" -> Labial
| "hi" -> High
| "lo" -> Low
| "back" -> Back
| "round" -> Rounded
| "velaric" -> Velaric
| "tense" -> Tense
| "long" -> Long
| "hitone" -> HighTone
| "hireg" -> HighReg
| _ -> failwith "not a valid feature"
(** Check if a segment has a specific feature with a given value *)
let has_feature (value, feature_name) segment =
List.exists (fun (v, f) -> v = value && f = feature_name) segment
(** Create a feature test function for use in the decision tree *)
let test feature_spec segment = has_feature feature_spec segment
(* end *)
|