Copyright | (c) 2021 Rory Tyler Hayford |
---|---|
License | BSD-3-Clause |
Maintainer | rory.hayford@protonmail.com |
Stability | experimental |
Portability | GHC |
Safe Haskell | None |
Language | Haskell2010 |
Parser for IPA literals
Synopsis
- parseSegment :: Text -> Either IPAException Segment
- segmentP :: Parser Segment
- parseSyllable :: MultiSegment t => Text -> Either IPAException (Syllable t)
- syllableP :: MultiSegment t => Parser (Syllable t)
- parseSyllables :: (MultiSegment t, Monoid (t (Syllable t))) => Text -> Either IPAException (t (Syllable t))
- syllablesP :: (MultiSegment t, Monoid (t (Syllable t))) => Parser (t (Syllable t))
- parseSegmentXSampa :: Text -> Either IPAException Segment
- segmentXSampaP :: Parser Segment
- parseSyllableXSampa :: MultiSegment t => Text -> Either IPAException (Syllable t)
- parseSyllablesXSampa :: (MultiSegment t, Monoid (t (Syllable t))) => Text -> Either IPAException (t (Syllable t))
- syllableXSampaP :: MultiSegment t => Parser (Syllable t)
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 Syllable
s. 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
parseSegmentXSampa :: Text -> Either IPAException Segment Source #
As parseSegment
, but in X-SAMPA notation
Parsing syllables
parseSyllableXSampa :: MultiSegment t => Text -> Either IPAException (Syllable t) Source #
As parseSyllable
, but in X-SAMPA notation
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