summaryrefslogtreecommitdiff
path: root/sorsyl/lib/sonority.mli
blob: 3e9166e2d9af05ebd8a7983b5590ec0b8db1626b (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
(** Sonority module for determining the sonority of phonetic segments.

    This module provides functionality to determine the sonority of IPA
    (International Phonetic Alphabet) segments on a scale of 1 to 9, where:
    - 9: Low vowels (most sonorous)
    - 8: High vowels
    - 7: Glides/approximants
    - 6: Liquids
    - 5: Nasals
    - 4: Voiced fricatives
    - 3: Voiceless fricatives
    - 2: Voiced stops
    - 1: Voiceless stops (least sonorous)

    Example usage:
    {[
      (* Initialize the module with the data directory *)
      Sonority.init "./data";;

      (* Get sonority values for IPA segments *)
      Sonority.sonority "a";;

      (* Returns 9 - low vowel *)
      Sonority.sonority "p";;

      (* Returns 1 - voiceless stop *)
      Sonority.sonority "l" (* Returns 6 - liquid *)
    ]} *)

val init : string -> unit
(** Initialize the sonority module with the data directory. This must be called
    before using other functions.
    @param data_dir The directory containing the ipa_all.csv file
    @raise Sys_error if the CSV file cannot be found or read *)

val sonority : string -> int
(** Get the sonority value (1-9) for an IPA character.
    @param ipa The IPA character/segment to analyze
    @return The sonority value between 1 and 9
    @raise Failure if the IPA segment is not recognized *)

val sonority_from_features : Feature.segment -> int
(** Get the sonority value from a feature specification. This is useful when you
    already have the phonological features of a segment and don't need to look
    it up by IPA symbol.
    @param segment The list of feature specifications
    @return The sonority value between 1 and 9 *)