Safe Haskell | Safe-Infered |
---|
This module provides basic datatypes specific to Tree Adjoining Grammar (TAG) elementary trees and some low-level operations.
- type Tags = Map String [TagElem]
- data TagElem = TE {}
- class TagItem t where
- data TagSite = TagSite {}
- type TagDerivation = [DerivationStep]
- data DerivationStep
- dsChild :: DerivationStep -> Text
- dsParent :: DerivationStep -> Maybe Text
- dsParentSite :: DerivationStep -> Maybe Text
- ts_synIncomplete, ts_tbUnificationFailure :: String
- ts_semIncomplete :: [Literal GeniVal] -> String
- ts_rootFeatureMismatch :: Flist GeniVal -> String
- addToTags :: Tags -> String -> TagElem -> Tags
- tagLeaves :: TagElem -> [(NodeName, UninflectedDisjunction)]
- getLexeme :: GNode GeniVal -> [Text]
- toTagSite :: GNode GeniVal -> TagSite
- setTidnums :: [TagElem] -> [TagElem]
- plugTree :: Tree NodeName -> NodeName -> Tree NodeName -> Tree NodeName
- spliceTree :: NodeName -> Tree NodeName -> NodeName -> Tree NodeName -> Tree NodeName
- mapBySem :: TagItem t => [t] -> Map (Literal GeniVal) [t]
- collect :: Collectable a => a -> Map CollectedVar Int -> Map CollectedVar Int
- detectSites :: Tree (GNode GeniVal) -> ([NodeName], [NodeName], [NodeName])
Documentation
type Tags = Map String [TagElem]
An anchored grammar. The grammar associates a set of semantic predicates to a list of trees each.
class TagItem t where
tgSemantics :: t -> Sem
data TagSite
type TagDerivation = [DerivationStep]
data DerivationStep
dsChild :: DerivationStep -> Text
dsParent :: DerivationStep -> Maybe Text
dsParentSite :: DerivationStep -> Maybe Text
ts_semIncomplete :: [Literal GeniVal] -> String
addToTags :: Tags -> String -> TagElem -> Tags
addTags
tags key elem
adds elem
to the the list of elements associated
to the key
tagLeaves :: TagElem -> [(NodeName, UninflectedDisjunction)]
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.
setTidnums :: [TagElem] -> [TagElem]
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 NodeName
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!
:: 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]
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.
collect :: Collectable a => a -> Map CollectedVar Int -> Map CollectedVar Int
collect x m
increments our count for any variables in x
(adds not-yet-seen variables as needed)