summaryrefslogtreecommitdiff
path: root/sorsyl/lib/feature.ml
diff options
context:
space:
mode:
Diffstat (limited to 'sorsyl/lib/feature.ml')
-rw-r--r--sorsyl/lib/feature.ml39
1 files changed, 38 insertions, 1 deletions
diff --git a/sorsyl/lib/feature.ml b/sorsyl/lib/feature.ml
index 280977b..f67a300 100644
--- a/sorsyl/lib/feature.ml
+++ b/sorsyl/lib/feature.ml
@@ -44,7 +44,9 @@ let value_of_string = function
| "0" -> Zero
| s -> failwith (Printf.sprintf "Invalid feature value: %s" s)
-let string_of_feature = function
+let string_of_value = function Plus -> "+" | Minus -> "-" | Zero -> "0"
+
+let feature_of_string = function
| "syl" -> Syllabic
| "son" -> Sonorant
| "cons" -> Consonantal
@@ -71,6 +73,41 @@ let string_of_feature = function
| "hireg" -> HighReg
| _ -> failwith "not a valid feature"
+let string_of_feature = function
+ | Syllabic -> "syl"
+ | Sonorant -> "son"
+ | Consonantal -> "cons"
+ | Continuant -> "cont"
+ | DelayedRelease -> "delrel"
+ | Lateral -> "lat"
+ | Nasal -> "nas"
+ | Strident -> "strid"
+ | Voiced -> "voi"
+ | SpreadGlottis -> "sg"
+ | ConstrictedGlottis -> "cg"
+ | Anterior -> "ant"
+ | Coronal -> "cor"
+ | Distributed -> "distr"
+ | Labial -> "lab"
+ | High -> "hi"
+ | Low -> "lo"
+ | Back -> "back"
+ | Rounded -> "round"
+ | Velaric -> "velaric"
+ | Tense -> "tense"
+ | Long -> "long"
+ | HighTone -> "hitone"
+ | HighReg -> "hireg"
+
+let string_of_segment segment =
+ Base.List.fold segment ~init:"" ~f:(fun acc (feature, value) ->
+ let item =
+ Printf.sprintf "%s:%s"
+ (string_of_feature feature)
+ (string_of_value value)
+ in
+ Printf.sprintf "%s\n%s" acc item)
+
(** 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