GenI-0.20.2: A natural language generator (specifically, an FB-LTAG surface realiser)Source codeContentsIndex
NLP.GenI.Builder
Synopsis
data Builder st it pa = Builder {
init :: Input -> pa -> (st, Statistics)
step :: BuilderState st ()
stepAll :: BuilderState st ()
finished :: st -> Bool
unpack :: st -> [Output]
partial :: st -> [Output]
}
type Output = (LemmaPlusSentence, Derivation)
type Derivation = TagDerivation
data Input = Input {
inSemInput :: SemInput
inLex :: [ILexEntry]
inCands :: [(TagElem, BitVector)]
}
type SentenceAut = NFA Int LemmaPlus
data UninflectedDisjunction = UninflectedDisjunction [String] Flist
type BuilderState s a = StateT s (State Statistics) a
preInit :: Input -> Params -> (Input, (Int, Int, Int), PolResult)
unlessEmptySem :: Input -> Params -> a -> a
run :: Builder st it Params -> Input -> Params -> (st, Statistics)
type SemBitMap = Map Pred BitVector
defineSemanticBits :: Sem -> SemBitMap
semToBitVector :: SemBitMap -> Sem -> BitVector
bitVectorToSem :: SemBitMap -> BitVector -> Sem
type IafMap = Map String Sem
dependentSem :: IafMap -> String -> Sem
literalArgs :: Pred -> [GeniVal]
semToIafMap :: Sem -> IafMap
fromUniConst :: Monad m => GeniVal -> m String
getIdx :: Flist -> [GeniVal]
ts_iafFailure :: [String] -> [Pred] -> String
recalculateAccesibility :: IafAble a => a -> a
iafBadSem :: IafAble a => IafMap -> SemBitMap -> BitVector -> (a -> BitVector) -> a -> BitVector
class IafAble a where
iafAcc :: a -> [String]
iafInacc :: a -> [String]
iafSetAcc :: [String] -> a -> a
iafSetInacc :: [String] -> a -> a
iafNewAcc :: a -> [String]
defaultStepAll :: Builder st it pa -> BuilderState st ()
type DispatchFilter s a = a -> s (Maybe a)
(>-->) :: Monad s => DispatchFilter s a -> DispatchFilter s a -> DispatchFilter s a
nullFilter :: Monad s => DispatchFilter s a
condFilter :: Monad s => (a -> Bool) -> DispatchFilter s a -> DispatchFilter s a -> DispatchFilter s a
modifyStats :: (Metric -> Metric) -> BuilderState st ()
incrCounter :: String -> Int -> BuilderState st ()
queryCounter :: String -> Statistics -> Maybe Int
initStats :: Params -> Statistics
namedMetric :: String -> Metric
defaultMetricNames :: [String]
chart_size :: String
num_comparisons :: String
num_iterations :: String
nullBuilder :: Builder () (NullState ()) Params
type NullState a = BuilderState () a
initNullBuilder :: Input -> Params -> ((), Statistics)
lexicalSelection :: Derivation -> [String]
data LemmaPlus = LemmaPlus {
lpLemma :: String
lpFeats :: Flist
}
type LemmaPlusSentence = [LemmaPlus]
parsecToJSON :: Monad m => String -> CharParser () b -> String -> m b
Documentation
data Builder st it pa Source
Constructors
Builder
init :: Input -> pa -> (st, Statistics)
step :: BuilderState st ()
stepAll :: BuilderState st ()
finished :: st -> Bool
unpack :: st -> [Output]
partial :: st -> [Output]
type Output = (LemmaPlusSentence, Derivation)Source
type Derivation = TagDerivationSource
data Input Source
Constructors
Input
inSemInput :: SemInput
inLex :: [ILexEntry]for the debugger
inCands :: [(TagElem, BitVector)]tag tree
type SentenceAut = NFA Int LemmaPlusSource
data UninflectedDisjunction Source
Constructors
UninflectedDisjunction [String] Flist
show/hide Instances
type BuilderState s a = StateT s (State Statistics) aSource
preInit :: Input -> Params -> (Input, (Int, Int, Int), PolResult)Source
unlessEmptySem :: Input -> Params -> a -> aSource
Equivalent to id unless the input contains an empty or uninstatiated semantics
run :: Builder st it Params -> Input -> Params -> (st, Statistics)Source

Performs surface realisation from an input semantics and a lexical selection.

Statistics tracked

  • pol_used_bundles - number of bundled paths through the polarity automaton. see automatonPathSets
  • pol_used_paths - number of paths through the final automaton
  • pol_seed_paths - number of paths through the seed automaton (i.e. with no polarities). This is normally just 1, unless you have multi-literal semantics
  • pol_total_states - combined number of states in the all the polarity automata
  • pol_total_tras - combined number of transitions in all polarity automata
  • pol_max_states - number of states in the polarity automaton with the most states
  • pol_total_tras - number of transitions in the polarity automata with the most transitions
type SemBitMap = Map Pred BitVectorSource
defineSemanticBits :: Sem -> SemBitMapSource
assign a bit vector value to each literal in the semantics the resulting map can then be used to construct a bit vector representation of the semantics
semToBitVector :: SemBitMap -> Sem -> BitVectorSource
bitVectorToSem :: SemBitMap -> BitVector -> SemSource
type IafMap = Map String SemSource
dependentSem :: IafMap -> String -> SemSource
Return the literals of the semantics (in bit vector form) whose accesibility depends on the given index
literalArgs :: Pred -> [GeniVal]Source
Return the handle and arguments of a literal
semToIafMap :: Sem -> IafMapSource
fromUniConst :: Monad m => GeniVal -> m StringSource
Like fromGConst but only for the non-disjoint ones: meant to be used as Maybe or List
getIdx :: Flist -> [GeniVal]Source
ts_iafFailure :: [String] -> [Pred] -> StringSource
recalculateAccesibility :: IafAble a => a -> aSource
Calculate the new set of accessibility/inaccesible indices, returning a a tuple of accesible / inaccesible indices
iafBadSemSource
:: IafAble a
=> IafMap
-> SemBitMapthe input semantics
-> BitVectorthe semantics of the item
-> a -> BitVector
-> a
-> BitVector
Return, in bitvector form, the portion of a semantics that is inaccesible from an item
class IafAble a whereSource
Methods
iafAcc :: a -> [String]Source
iafInacc :: a -> [String]Source
iafSetAcc :: [String] -> a -> aSource
iafSetInacc :: [String] -> a -> aSource
iafNewAcc :: a -> [String]Source
show/hide Instances
defaultStepAll :: Builder st it pa -> BuilderState st ()Source
Default implementation for the stepAll function in Builder
type DispatchFilter s a = a -> s (Maybe a)Source
(>-->) :: Monad s => DispatchFilter s a -> DispatchFilter s a -> DispatchFilter s aSource
Sequence two dispatch filters.
nullFilter :: Monad s => DispatchFilter s aSource
A filter that always fails (i.e. no filtering)
condFilter :: Monad s => (a -> Bool) -> DispatchFilter s a -> DispatchFilter s a -> DispatchFilter s aSource
If the item meets some condition, use the first filter, otherwise use the second one.
modifyStats :: (Metric -> Metric) -> BuilderState st ()Source
incrCounter :: String -> Int -> BuilderState st ()Source
queryCounter :: String -> Statistics -> Maybe IntSource
initStats :: Params -> StatisticsSource
namedMetric :: String -> MetricSource
defaultMetricNames :: [String]Source
chart_size :: StringSource
num_comparisons :: StringSource
num_iterations :: StringSource
nullBuilder :: Builder () (NullState ()) ParamsSource
type NullState a = BuilderState () aSource
initNullBuilder :: Input -> Params -> ((), Statistics)Source

Running the null builder allows you to track certain statistics

  • sem_literals - number of literals in the input semantics
  • lex_trees - total number of lexically selected trees
lexicalSelection :: Derivation -> [String]Source
The names of lexically selected chart items used in a derivation
data LemmaPlus Source
A lemma plus its morphological features
Constructors
LemmaPlus
lpLemma :: String
lpFeats :: Flist
show/hide Instances
type LemmaPlusSentence = [LemmaPlus]Source
A sentence composed of LemmaPlus instead of plain old words
parsecToJSON :: Monad m => String -> CharParser () b -> String -> m bSource
Produced by Haddock version 2.6.0