partage-0.1.0.1: Parsing factorized

Safe HaskellSafe
LanguageHaskell2010

NLP.Partage.FactGram

Contents

Description

TAG conversion into flat production rules.

Synopsis

Factorized grammar

type FactGram n t = Set (Rule n t) Source

Factorized grammar: a set of flat production rules.

data Rule n t Source

A production rule, responsible for recognizing a specific (unique) non-trivial (of height > 0) subtree of an elementary grammar tree. Due to potential subtree sharing, a single rule can be responsible for recognizing a subtree common to many different elementary trees.

Invariants:

Constructors

Rule 

Fields

headR :: Lab n t

Head of the rule

bodyR :: [Lab n t]

Body of the rule

Instances

(Eq n, Eq t) => Eq (Rule n t) Source 
(Ord n, Ord t) => Ord (Rule n t) Source 
(Show n, Show t) => Show (Rule n t) Source 

data Lab n t Source

A label is a data type over which flat production rules are constructed. In particular, it describes what information is stored in the heads of rules, as well as in the elements of the their bodies.

Constructors

NonT

A non-terminal symbol originating from a branching, non-spine node, optionally marked with a SymID if originating from an internal (non-root, non-leaf) node

Fields

nonTerm :: n
 
labID :: Maybe SymID
 
Term t

A terminal symbol

AuxRoot

A non-terminal originating from a root of an auxiliary tree

Fields

nonTerm :: n
 
AuxFoot

A non-terminal originating from a foot of an auxiliary tree

Fields

nonTerm :: n
 
AuxVert

A non-terminal originating from a spine of an auxiliary tree (unless root or foot)

Fields

nonTerm :: n
 
symID :: SymID
 

Instances

(Eq n, Eq t) => Eq (Lab n t) Source 
(Ord n, Ord t) => Ord (Lab n t) Source 
(Show n, Show t) => Show (Lab n t) Source 

Grammar flattening

flattenNoSharing :: (Monad m, Ord n, Ord t) => [Either (Tree n t) (AuxTree n t)] -> m (FactGram n t) Source

Compile the given grammar into the list of rules. No structure sharing takes place here.

flattenWithSharing :: (Functor m, Monad m, Ord n, Ord t) => [Either (Tree n t) (AuxTree n t)] -> m (FactGram n t) Source

Compile the given grammar into the list of rules. Common subtrees are shared.