Copyright | © 2016-2017 George Steel and Peter Jurgec |
---|---|
License | GPL-2+ |
Maintainer | george.steel@gmail.com |
Safe Haskell | None |
Language | Haskell2010 |
Data structures and functions for working with phonological features and natural classes.
Feature tables are designed work with strings reperesented as lists of SegRef
indices into their internal segment lists, enabling processing with fast array lookups even with non-contiguous sets of segments.
- data FeatureState
- newtype SegRef = Seg Int
- data FeatureTable sigma = FeatureTable {}
- srBounds :: FeatureTable sigma -> (SegRef, SegRef)
- ftlook :: FeatureTable sigma -> SegRef -> Int -> FeatureState
- segsToRefs :: Ord sigma => FeatureTable sigma -> [sigma] -> [SegRef]
- refsToSegs :: FeatureTable sigma -> [SegRef] -> [sigma]
- csvToFeatureTable :: Ord sigma => (String -> sigma) -> String -> Maybe (FeatureTable sigma)
- featureTableToCsv :: (sigma -> String) -> FeatureTable sigma -> String
- data NaturalClass = NClass {
- isInverted :: !Bool
- featureList :: [(FeatureState, Text)]
- classToSeglist :: FeatureTable sigma -> NaturalClass -> SegSet SegRef
- data GlobReps
- data ClassGlob = ClassGlob !Bool !Bool [(GlobReps, NaturalClass)]
- classesToLists :: FeatureTable sigma -> ClassGlob -> ListGlob SegRef
- cgMatchCounter :: FeatureTable sigma -> ClassGlob -> ShortDFST SegRef
Phonological Features
data FeatureState Source #
Enumeration for feature states (can be +,-,0)
Indices for segment lookup table
data FeatureTable sigma Source #
Type for phonological feature table. Segments and features are referred to by indices so this structure includes lookup tables for those.
ftlook :: FeatureTable sigma -> SegRef -> Int -> FeatureState Source #
Shortcut for feature table array access
segsToRefs :: Ord sigma => FeatureTable sigma -> [sigma] -> [SegRef] Source #
Convert a string of raw segments to a string of SegRef
s. Skips unrecognisable segments.
refsToSegs :: FeatureTable sigma -> [SegRef] -> [sigma] Source #
Convert a string of SegRef
s back to segments
csvToFeatureTable :: Ord sigma => (String -> sigma) -> String -> Maybe (FeatureTable sigma) Source #
Parse feature table from CSV.
To use a feature table other than the default IPA one, you may define it in CSV format (RFC 4180). The segment names are defined by the first row (they may be any strings as long as they are all distinct, i.e. no duplicate names) and the feature names are defined by the first column (they are not hard-coded). Data cells should contain +
, -
, or 0
for binary features and +
or 0
for privative features (where we do not want a minus set that could form classes).
As a simple example, consider the following CSV file, defining three segments (a, n, and t), and two features (vowel and nasal).
,a,n,t vowel,+,-,- nasal,0,+,-
If a row contains a different number of cells (separated by commas) than the header line, is rejected as invalid and does not define a feature (and will not be dispayed in the formatted feature table). If the CSV which is entered has duplicate segment names, no segments, or no valid features, the entire table is rejected (indicated by a red border around the text area, green is normal) and the last valid table is used and displayed.
featureTableToCsv :: (sigma -> String) -> FeatureTable sigma -> String Source #
Cave a modified feature table to CSV format
Natural Classes
data NaturalClass Source #
Representation of a natural class as a list of features and their states. Can ahso handle inverted classes.
NClass | |
|
Eq NaturalClass Source # | |
Ord NaturalClass Source # | |
Read NaturalClass Source # | |
Show NaturalClass Source # | Uses SPE format |
NFData NaturalClass Source # | |
classToSeglist :: FeatureTable sigma -> NaturalClass -> SegSet SegRef Source #
Convert a class to a SegSet
Type for Glob quantifiers
Globs using NaturalClass
instead of SegSet
ClassGlob !Bool !Bool [(GlobReps, NaturalClass)] |
classesToLists :: FeatureTable sigma -> ClassGlob -> ListGlob SegRef Source #
Convert to a ListGlob
cgMatchCounter :: FeatureTable sigma -> ClassGlob -> ShortDFST SegRef Source #
Create a DFST which counts the matches of the glob.