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

Safe HaskellSafe-Infered

NLP.GenI.Tag

Description

This module provides basic datatypes specific to Tree Adjoining Grammar (TAG) elementary trees and some low-level operations.

Synopsis

Documentation

type Tags = Map String [TagElem]Source

An anchored grammar. The grammar associates a set of semantic predicates to a list of trees each.

class TagItem t whereSource

TagItem is a generalisation of TagElem.

Instances

addToTags :: Tags -> String -> TagElem -> TagsSource

addTags tags key elem adds elem to the the list of elements associated to the key

tagLeaves :: TagElem -> [(NodeName, UninflectedDisjunction)]Source

Normally, extracting the sentences from a TAG tree would just consist of reading its leaves. But if you want the generator to return inflected forms instead of just lemmas, you also need to return the relevant features for each leaf. In TAG, or at least our use of it, the features come from the *pre-terminal* nodes, that is, not the leaves themselves but their parents. Another bit of trickiness: because of atomic disjunction, leaves might have more than one value, so we can't just return a String lemma but a list of String, one for each possibility.

getLexeme :: GNode GeniVal -> [Text]Source

Try in order: lexeme, lexeme attributes, node name

setTidnums :: [TagElem] -> [TagElem]Source

Assigns a unique id to each element of this list, that is, an integer between 1 and the size of the list.

plugTree :: Tree NodeName -> NodeName -> Tree NodeName -> Tree NodeNameSource

Plug the first tree into the second tree at the specified node. Anything below the second node is silently discarded. We assume the trees are pluggable; it is treated as a bug if they are not!

spliceTreeSource

Arguments

:: NodeName

foot node of the aux tree

-> Tree NodeName

aux tree

-> NodeName

place to adjoin in target tree

-> Tree NodeName

target tree

-> Tree NodeName 

Given two trees auxt and t, splice the tree auxt into t via the TAG adjunction rule.

mapBySem :: TagItem t => [t] -> Map (Literal GeniVal) [t]Source

Sorts trees into a Map.Map organised by the first literal of their semantics. This is useful in at least three places: the polarity optimisation, the gui display code, and code for measuring the efficiency of GenI. Note: trees with a null semantics are filed under an empty predicate, if any.

detectSites :: Tree (GNode GeniVal) -> ([NodeName], [NodeName], [NodeName])Source

Given a tree(GNode) returns a list of substitution or adjunction nodes, as well as remaining nodes with a null adjunction constraint.