GenI-0.24.3: A natural language generator (specifically, an FB-LTAG surface realiser)

Safe HaskellNone




We use a flat semantics in GenI (bag of literals).



data Literal gv Source

A single semantic literal containing its handle, predicate, and arguments

This can be paramaterised on the kinds of variables it uses, for example, GeniVal for a semantics that you might still want to do unification on or Text if it's supposed to be ground.




lHandle :: gv

the handle can be seen as a special kind of argument; stored separately

lPredicate :: gv
lArgs :: [gv]

type Sem = [Literal GeniVal]Source

A semantics is just a set of literals.

type LitConstr = (Literal GeniVal, [Text])Source

A literal and any constraints associated with it (semantic input)

type SemInput = (Sem, Flist GeniVal, [LitConstr])Source

Semantics, index constraints, literal constraints

The intention here is that for (sem, icons, lcons) all (elem sem) lcons

emptyLiteral :: Literal GeniValSource

An empty literal, not sure you should really be using this

Utility functions

removeConstraints :: SemInput -> SemInputSource

Strip any index or literal constraints from an input. Use with care.

sortSem :: Ord a => [Literal a] -> [Literal a]Source

Default sorting for a semantics

compareOnLiteral :: Ord a => Literal a -> Literal a -> OrderingSource

Default comparison for a literal

sortByAmbiguity :: Sem -> SemSource

Sort primarily putting the ones with the most constants first and secondarily by the number of instances a predicate occurs (if plain string; atomic disjunction/vars treated as infinite)

class HasConstants a whereSource

Anything that we would want to count the number constants in (as opposed to variables)


constants :: a -> IntSource

Number of constants

displaySemInput :: ([LitConstr] -> Text) -> SemInput -> TextSource

Helper for displaying or pretty printing a semantic input

This gives you a bit of control over how each literal is displayed

isInternalHandle :: Text -> BoolSource

Is a handle generated by GenI. GenI lets you write literals without a handle; in these cases a unique handle is generated and hidden from the UI.


subsumeSem :: Sem -> Sem -> [(Sem, Subst)]Source

x subsumeSem y returns all the possible ways to unify x with some SUBSET of y so that x subsumes y. If x does NOT subsume y, we return the empty list.

subsumeSemH :: Sem -> Sem -> [(Sem, Subst)]Source

Helper for subsumeSem traversal

subsumeLiteral :: MonadUnify m => Literal GeniVal -> Literal GeniVal -> m (Literal GeniVal, Subst)Source

p1 subsumeLiteral p2 is the unification of p1 and p2 if both literals have the same arity, and the handles, predicates, and arguments in p1 all subsume their counterparts in p2


unifySem :: Sem -> Sem -> [(Sem, Subst)]Source

Return the list of minimal ways to unify two semantics, ie. where any literals that are not the product of a succesful unification really do not unify with anything else.

unifySemH :: Sem -> Sem -> [(Sem, Subst)]Source

Helper traversal for unifySem

unifyLiteral :: MonadUnify m => Literal GeniVal -> Literal GeniVal -> m (Literal GeniVal, Subst)Source

Two literals unify if they have the same arity, and their handles, predicates, and arguments also unify