| Copyright | See LICENSE file |
|---|---|
| License | BSD3 |
| Maintainer | Brad Neimann |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Brassica.Paradigm
Description
Synopsis
- module Text.Megaparsec.Error
- data Process
- type Affix = [Process]
- data Grammeme
- newtype AbstractGrammeme = AbstractGrammeme String
- data Condition
- data Feature = Feature Condition (Maybe FeatureName) [Grammeme]
- newtype FeatureName = FeatureName String
- data Statement
- type Paradigm = [Statement]
- parseParadigm :: String -> Either (ParseErrorBundle String Void) Paradigm
- formatNested :: (a -> String) -> ResultsTree a -> String
- applyParadigm :: Paradigm -> String -> ResultsTree String
- data ResultsTree a
- = Node [ResultsTree a]
- | Result a
- depth :: ResultsTree a -> Int
Re-export
module Text.Megaparsec.Error
Paradigm representation
Represents a single morphophonological process: currently, either
prefixation or suffixation of a String. The Int gives the
distance of the affix from the root.
Instances
A Grammeme represents one value of a grammatical feature: for
instance past, or dual. This can be realised as a Concrete affix,
or can be left Abstract so that it can be encoded in a cumulative
morph or similar.
(The name is from Wikipedia; it doesn’t seem widely-used, but I can find no better for this concept.)
Constructors
| Concrete Affix | |
| Abstract AbstractGrammeme |
newtype AbstractGrammeme Source #
An abstract identifier for a Grammeme.
Constructors
| AbstractGrammeme String |
Instances
| IsString AbstractGrammeme Source # | |
Defined in Brassica.Paradigm.Types Methods fromString :: String -> AbstractGrammeme # | |
| Show AbstractGrammeme Source # | |
Defined in Brassica.Paradigm.Types Methods showsPrec :: Int -> AbstractGrammeme -> ShowS # show :: AbstractGrammeme -> String # showList :: [AbstractGrammeme] -> ShowS # | |
| Eq AbstractGrammeme Source # | |
Defined in Brassica.Paradigm.Types Methods (==) :: AbstractGrammeme -> AbstractGrammeme -> Bool # (/=) :: AbstractGrammeme -> AbstractGrammeme -> Bool # | |
A condition which must be satisfied for a Feature to be
included in a word.
Constructors
| Always | Condition which is always satisfied |
| Is FeatureName Grammeme | Satisfied when the specified feature has been assigned to the
specified |
| Not FeatureName Grammeme | Satisfied when the specified feature has not been assigned
to the specified |
A grammatical feature, which may be realised by one of a
selection of Grammemes. A feature may be given a descriptive
name, as well as a condition which must be satisfied for the
Feature to be included in a word.
Constructors
| Feature Condition (Maybe FeatureName) [Grammeme] |
Instances
newtype FeatureName Source #
Name to identify a specific Feature.
Constructors
| FeatureName String |
Instances
| IsString FeatureName Source # | |
Defined in Brassica.Paradigm.Types Methods fromString :: String -> FeatureName # | |
| Show FeatureName Source # | |
Defined in Brassica.Paradigm.Types Methods showsPrec :: Int -> FeatureName -> ShowS # show :: FeatureName -> String # showList :: [FeatureName] -> ShowS # | |
| Eq FeatureName Source # | |
Defined in Brassica.Paradigm.Types | |
Each statement in a paradigm description specifies either a new
Feature, or a new mapping from a set of abstract grammemes to
their realisation.
Constructors
| NewFeature Feature | |
| NewMapping [AbstractGrammeme] Affix |
type Paradigm = [Statement] Source #
A paradigm is specified as a list of Statements. The order is
reflected in the output ResultsTree: the
root has one child for each grammeme in the first Feature, with
each child then having one child for each grammeme in the second
Feature, and so on.
Parsing and pretty-printing
parseParadigm :: String -> Either (ParseErrorBundle String Void) Paradigm Source #
Parse a String in Brassica paradigm syntax into a Paradigm.
Returns Left if the input string is malformed.
For details on the syntax, refer to https://github.com/bradrn/brassica/blob/v1.0.0/docs/Paradigm-Builder.md.
formatNested :: (a -> String) -> ResultsTree a -> String Source #
Formats a ResultsTree in a nested way, where the lowest-level
elements are separated by one space, the second-lowest are
separated by one newline, the third-lowest by two newlines, and so
on.
Paradigm application
applyParadigm :: Paradigm -> String -> ResultsTree String Source #
Apply the given Paradigm to a root, to produce all possible
derived forms.
data ResultsTree a Source #
Results from applying a Paradigm to a word, represented as a tree
containing each possible choice of Grammemes.
Constructors
| Node [ResultsTree a] | |
| Result a |
Instances
depth :: ResultsTree a -> Int Source #
Depth of a ResultsTree: i.e. how many levels of Nodes it
contains.