ipa-0.3.1.1: Internal Phonetic Alphabet (IPA)
Copyright(c) 2021 Rory Tyler Hayford
LicenseBSD-3-Clause
Maintainerrory.hayford@protonmail.com
Stabilityexperimental
PortabilityGHC
Safe HaskellNone
LanguageHaskell2010

Language.IPA.Parser

Description

Parser for IPA literals

Synopsis

IPA parsing

Parsing single segments

parseSegment :: Text -> Either IPAException Segment Source #

Parse a single literal segment in IPA notation, returning InvalidIPA upon failure and a Segment upon success. Note that supplying two or more segment literals will cause the parse to fail

>>> parseSegment "ɨːː"
Right (WithSegmentalFeature (Length OverLong) (Vowel Close Central Unrounded))
>>> parseSegment "ɨːːb"
Left (InvalidIPA "Failed to parse character 'b'")

segmentP :: Parser Segment Source #

Parser for segments. This function is exposed to allow users to create more specific parsers for multi-segment sequences

Parsing syllables

parseSyllable :: MultiSegment t => Text -> Either IPAException (Syllable t) Source #

Parse a literal syllable in IPA notation, returning InvalidIPA upon failure and a Syllable upon success, where the syllable is parameterized by some type t satisfying a MultiSegment constraint. Note that, as with parseSegment, supplying two or more syllable literals will cause the parse to fail

>>> parseSyllable @[] "ma˧˥"
Right (WithSuprasegmentalFeature (LexicalToneContour HighRising)
      (Syllable [Consonant (Pulmonic Voiced Bilabial Nasal),Vowel Open Front Unrounded]))

syllableP :: MultiSegment t => Parser (Syllable t) Source #

Parser for syllables. This function is exposed to allow users to create more specific parsers for aggregations of multiple syllables

parseSyllables :: (MultiSegment t, Monoid (t (Syllable t))) => Text -> Either IPAException (t (Syllable t)) Source #

Parse several syllables into a container parameterized by the same type as that parameterizing the individual Syllables. Whitespace between syllables is interpreted as a syllable boundary

>>> parseSyllables @[] "haːj˧ ɓaː˧"
Right [ WithSuprasegmentalFeature (LevelLexicalTone MidTone)
          (Syllable [ Consonant (Pulmonic Voiceless Glottal (Fricative NonSibilant))
                    , WithSegmentalFeature (Length Long) (Vowel Open Front Unrounded)
                    , Consonant (Pulmonic Voiced Palatal Approximant)
                    ])
      , WithSuprasegmentalFeature (LevelLexicalTone MidTone)
          (Syllable [ Consonant (Implosive Voiced Bilabial)
                    , WithSegmentalFeature (Length Long) (Vowel Open Front Unrounded)
                    ])
      ]

syllablesP :: (MultiSegment t, Monoid (t (Syllable t))) => Parser (t (Syllable t)) Source #

Parser for poly-syllabic sequences, with individual syllables separated by (optional) whitespace

X-SAMPA parsing

Parsing single segments

segmentXSampaP :: Parser Segment Source #

As segmentP, but in X-SAMPA notation

Parsing syllables

parseSyllablesXSampa :: (MultiSegment t, Monoid (t (Syllable t))) => Text -> Either IPAException (t (Syllable t)) Source #

As parseSyllables, but in X-SAMPA notation

syllableXSampaP :: MultiSegment t => Parser (Syllable t) Source #

As syllableP, but in X-SAMPA notation