summaryrefslogtreecommitdiff
path: root/sorsyl/lib/syllable.mli
blob: e16364f0036cea20a3894839d7dcfe8b7f7f83f6 (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
(** Module for representing syllables and their components *)

(** Type representing a syllable with its phonological components *)
type t = {
  onset : string;      (** Initial consonants *)
  medial : string;     (** Medial consonants (between onset and nucleus) *)
  nucleus : string;    (** Vowel core of the syllable *)
  coda : string;       (** Final consonants *)
  tone : string;       (** Tonal information *)
  spelling : string;   (** Orthographic representation *)
  start_idx : int;     (** Start position in the word *)
  end_idx : int;       (** End position in the word *)
  stressed : bool;     (** Whether this syllable is stressed *)
}

(** Empty syllable constant *)
val empty : t

(** Create a syllable with specified components *)
val create : 
  ?onset:string -> 
  ?medial:string -> 
  ?nucleus:string -> 
  ?coda:string -> 
  ?tone:string ->
  ?spelling:string ->
  ?start_idx:int ->
  ?end_idx:int ->
  ?stressed:bool ->
  unit -> t

(** Get the complete syllable string *)
val all : t -> string

(** Get the rhyme (medial + nucleus + coda) *)
val rhyme : t -> string

(** Check if the nucleus contains length marker *)
val is_long : t -> bool

(** Finalize a syllable - determine if it's stressed based on position relative to stress marker *)
val finalize : t -> end_idx:int -> stress_idx:int -> t

(** Pretty print a syllable with Unicode box drawing *)
val pretty_print : t -> string

(** Convert to string representation *)
val to_string : t -> string

(** Append operations *)
val append_onset : t -> string -> t
val append_nucleus : t -> string -> t
val append_coda : t -> string -> t
val append_tone : t -> string -> t