brassica-1.0.0: Featureful sound change applier
CopyrightSee LICENSE file
LicenseBSD3
MaintainerBrad Neimann
Safe HaskellSafe-Inferred
LanguageHaskell2010

Brassica.Paradigm

Description

 
Synopsis

Re-export

Paradigm representation

data Process Source #

Represents a single morphophonological process: currently, either prefixation or suffixation of a String. The Int gives the distance of the affix from the root.

Constructors

Prefix Int String 
Suffix Int String 

Instances

Instances details
Show Process Source # 
Instance details

Defined in Brassica.Paradigm.Types

Eq Process Source # 
Instance details

Defined in Brassica.Paradigm.Types

Methods

(==) :: Process -> Process -> Bool #

(/=) :: Process -> Process -> Bool #

type Affix = [Process] Source #

A single affix (using the term in a wide sense) can be thought of as a list of morphophonological processes. For instance, the Berber feminine circumfix t--t might be represented as [Prefix 1 "t", Suffix 1 "t"] :: Affix.

data Grammeme Source #

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.)

Instances

Instances details
Show Grammeme Source # 
Instance details

Defined in Brassica.Paradigm.Types

Eq Grammeme Source # 
Instance details

Defined in Brassica.Paradigm.Types

data Condition Source #

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 Grammeme

Not FeatureName Grammeme

Satisfied when the specified feature has not been assigned to the specified Grammeme

Instances

Instances details
Show Condition Source # 
Instance details

Defined in Brassica.Paradigm.Types

Eq Condition Source # 
Instance details

Defined in Brassica.Paradigm.Types

data Feature Source #

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.

Instances

Instances details
Show Feature Source # 
Instance details

Defined in Brassica.Paradigm.Types

Eq Feature Source # 
Instance details

Defined in Brassica.Paradigm.Types

Methods

(==) :: Feature -> Feature -> Bool #

(/=) :: Feature -> Feature -> Bool #

newtype FeatureName Source #

Name to identify a specific Feature.

Constructors

FeatureName String 

Instances

Instances details
IsString FeatureName Source # 
Instance details

Defined in Brassica.Paradigm.Types

Show FeatureName Source # 
Instance details

Defined in Brassica.Paradigm.Types

Eq FeatureName Source # 
Instance details

Defined in Brassica.Paradigm.Types

data Statement Source #

Each statement in a paradigm description specifies either a new Feature, or a new mapping from a set of abstract grammemes to their realisation.

Instances

Instances details
Show Statement Source # 
Instance details

Defined in Brassica.Paradigm.Types

Eq Statement Source # 
Instance details

Defined in Brassica.Paradigm.Types

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

Instances details
Foldable ResultsTree Source # 
Instance details

Defined in Brassica.Paradigm.Apply

Methods

fold :: Monoid m => ResultsTree m -> m #

foldMap :: Monoid m => (a -> m) -> ResultsTree a -> m #

foldMap' :: Monoid m => (a -> m) -> ResultsTree a -> m #

foldr :: (a -> b -> b) -> b -> ResultsTree a -> b #

foldr' :: (a -> b -> b) -> b -> ResultsTree a -> b #

foldl :: (b -> a -> b) -> b -> ResultsTree a -> b #

foldl' :: (b -> a -> b) -> b -> ResultsTree a -> b #

foldr1 :: (a -> a -> a) -> ResultsTree a -> a #

foldl1 :: (a -> a -> a) -> ResultsTree a -> a #

toList :: ResultsTree a -> [a] #

null :: ResultsTree a -> Bool #

length :: ResultsTree a -> Int #

elem :: Eq a => a -> ResultsTree a -> Bool #

maximum :: Ord a => ResultsTree a -> a #

minimum :: Ord a => ResultsTree a -> a #

sum :: Num a => ResultsTree a -> a #

product :: Num a => ResultsTree a -> a #

Functor ResultsTree Source # 
Instance details

Defined in Brassica.Paradigm.Apply

Methods

fmap :: (a -> b) -> ResultsTree a -> ResultsTree b #

(<$) :: a -> ResultsTree b -> ResultsTree a #

Show a => Show (ResultsTree a) Source # 
Instance details

Defined in Brassica.Paradigm.Apply

depth :: ResultsTree a -> Int Source #

Depth of a ResultsTree: i.e. how many levels of Nodes it contains.