-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | A natural language generator (specifically, an FB-LTAG surface realiser)
--
-- A natural language generator (specifically, an FB-LTAG surface
-- realiser)
@package GenI
@version 0.20
module NLP.GenI.Statistics
data Statistics
type StatisticsState a = forall m. (MonadState Statistics m) => m a
emptyStats :: Statistics
showFinalStats :: Statistics -> String
initialStatisticsStateFor :: (MonadState Statistics m) => (m a -> Statistics -> b) -> m a -> b
-- | Adds a metric at the beginning of the list (note we reverse the order
-- whene we want to print the metrics)
addMetric :: Metric -> StatisticsState ()
data Metric
IntMetric :: String -> Int -> Metric
queryMetrics :: (Metric -> Maybe a) -> Statistics -> [a]
updateMetrics :: (Metric -> Metric) -> Statistics -> Statistics
incrIntMetric :: String -> Int -> Metric -> Metric
queryIntMetric :: String -> Metric -> Maybe Int
instance [overlap ok] JSON Statistics
instance [overlap ok] Show Metric
module NLP.GenI.PolarityTypes
newtype PolarityKey
PolarityKey :: String -> PolarityKey
fromPolarityKey :: PolarityKey -> String
-- | PolarityAttr is something you want to perform detect polarities
-- on.
data PolarityAttr
SimplePolarityAttr :: String -> PolarityAttr
spkAtt :: PolarityAttr -> String
-- | RestrictedPolarityKey c att is a polarity key in which we
-- only pay attention to nodes that have the category c. This
-- makes it possible to have polarities for a just a small subset of
-- nodes
RestrictedPolarityAttr :: String -> String -> PolarityAttr
_rpkCat :: PolarityAttr -> String
rpkAtt :: PolarityAttr -> String
readPolarityAttrs :: String -> Set PolarityAttr
instance [overlap ok] Typeable PolarityAttr
instance [overlap ok] Typeable PolarityKey
instance [overlap ok] Eq PolarityAttr
instance [overlap ok] Ord PolarityAttr
instance [overlap ok] Show PolarityKey
instance [overlap ok] Eq PolarityKey
instance [overlap ok] Ord PolarityKey
instance [overlap ok] Data PolarityKey
instance [overlap ok] Show PolarityAttr
-- | This module provides some very generic, non-GenI specific functions on
-- strings, trees and other miscellaneous odds and ends. Whenever
-- possible, one should try to replace these functions with versions that
-- are available in the standard libraries, or the Haskell platform ones,
-- or on hackage.
module NLP.GenI.General
-- | putStr on stderr
ePutStr :: String -> IO ()
ePutStrLn :: String -> IO ()
eFlush :: IO ()
-- | Using readFile' can be a good idea if you're dealing with not-so-huge
-- files (i.e. where you don't want lazy evaluation), because it ensures
-- that the handles are closed. No more ``too many open files''
readFile' :: FilePath -> IO String
lazySlurp :: ForeignPtr Word8 -> Int -> Int -> IO String
withTimeout :: Integer -> IO a -> IO a -> IO a
-- | Like exitFailure, except that we return with a code that we reserve
-- for timing out
exitTimeout :: IO ()
-- | Drop all characters up to and including the one in question
dropTillIncluding :: Char -> String -> String
trim :: String -> String
-- | Make the first character of a string upper case
toUpperHead :: String -> String
-- | Make the first character of a string lower case
toLowerHead :: String -> String
-- | An alphanumeric sort is one where you treat the numbers in the string
-- as actual numbers. An alphanumeric sort would put x2 before x100,
-- because 2 < 10, wheraeas a naive sort would put it the other way
-- around because the characters 1 < 2. To sort alphanumerically, just
-- 'sortBy (comparing toAlphaNum)'
toAlphaNum :: String -> [AlphaNum]
fst3 :: (a, b, c) -> a
snd3 :: (a, b, c) -> b
thd3 :: (a, b, c) -> c
-- | A strict version of map
map' :: (a -> b) -> [a] -> [b]
-- | Makes sure that index s is in the bounds of list l. Surely there must
-- be some more intelligent way to deal with this.
boundsCheck :: Int -> [a] -> Bool
-- | True if the intersection of two lists is empty.
isEmptyIntersect :: (Eq a) => [a] -> [a] -> Bool
-- | Serves the same function as groupBy. It groups together items
-- by some property they have in common. The difference is that the
-- property is used as a key to a Map that you can lookup.
groupByFM :: (Ord b) => (a -> b) -> [a] -> (Map b [a])
-- | Same as groupByFM, except that we let an item appear in
-- multiple groups. The fn extracts the property from the item, and
-- returns multiple results in the form of a list
multiGroupByFM :: (Ord b) => (a -> [b]) -> [a] -> (Map b [a])
insertToListMap :: (Ord b) => b -> a -> Map b [a] -> Map b [a]
-- | Convert a list of items into a list of tuples (a,b) where a is an item
-- in the list and b is the number of times a in occurs in the list.
groupAndCount :: (Eq a, Ord a) => [a] -> [(a, Int)]
combinations :: [[a]] -> [[a]]
mapMaybeM :: (Monad m) => (a -> m (Maybe b)) -> [a] -> m [b]
-- | Return the list, modifying only the first matching item.
repList :: (a -> Bool) -> (a -> a) -> [a] -> [a]
-- | Strict version of mapTree (for non-strict, just use fmap)
mapTree' :: (a -> b) -> Tree a -> Tree b
-- | Like filter, except on Trees. Filter might not be a good name,
-- though, because we return a list of nodes, not a tree.
filterTree :: (a -> Bool) -> Tree a -> [a]
-- | The leaf nodes of a Tree
treeLeaves :: Tree a -> [a]
-- | Return pairs of (parent, terminal)
preTerminals :: Tree a -> [(a, a)]
-- | repNode fn filt t returns a version of t in
-- which the first node which filt matches is transformed using
-- fn.
repNode :: (Tree a -> Tree a) -> (Tree a -> Bool) -> Tree a -> Maybe (Tree a)
-- | Like repNode except that it performs the operations on all
-- nodes that match and doesn't care if any nodes match or not
repAllNode :: (Tree a -> Tree a) -> (Tree a -> Bool) -> Tree a -> Tree a
-- | Like repNode but on a list of tree nodes
listRepNode :: (Tree a -> Tree a) -> (Tree a -> Bool) -> [Tree a] -> ([Tree a], Bool)
-- | Replace a node in the tree in-place with another node; keep the
-- children the same. If the node is not found in the tree, or if there
-- are multiple instances of the node, this is treated as an error.
repNodeByNode :: (a -> Bool) -> a -> Tree a -> Tree a
type Interval = (Int, Int)
-- | Add two intervals
(!+!) :: Interval -> Interval -> Interval
-- | ival x builds a trivial interval from x to x
ival :: Int -> Interval
showInterval :: Interval -> String
type BitVector = Integer
-- | displays a bit vector, using a minimum number of bits
showBitVector :: Int -> BitVector -> String
-- | errors specifically in GenI, which is very likely NOT the user's
-- fault.
geniBug :: String -> a
instance [overlap ok] Eq AlphaNum
instance [overlap ok] Typeable TimeOut
instance [overlap ok] Ord AlphaNum
module NLP.GenI.GeniVal
data GeniVal
-- | atomic disjunction - constant x | y | z
GConst :: [String] -> GeniVal
-- | variable
GVar :: String -> GeniVal
-- | anonymous
GAnon :: GeniVal
isConst :: GeniVal -> Bool
isVar :: GeniVal -> Bool
isAnon :: GeniVal -> Bool
-- | (assumes that it's a GConst!)
fromGConst :: GeniVal -> [String]
-- | (assumes that it's a GVar!)
fromGVar :: GeniVal -> String
type Subst = Map String GeniVal
-- | unify performs unification on two lists of GeniVal. If
-- unification succeeds, it returns Just (r,s) where verb!r! is
-- the result of unification and verb!s! is a list of substitutions that
-- this unification results in.
unify :: (Monad m) => [GeniVal] -> [GeniVal] -> m ([GeniVal], Subst)
-- | Note that the first Subst is assumed to come chronologically before
-- the second one; so merging { X -> Y } and { Y -> 3
-- } should give us { X -> 3; Y -> 3 };
--
-- See prependToSubst for a warning!
mergeSubst :: Subst -> Subst -> Subst
-- | Add to variable replacement to a Subst that logical comes
-- before the other stuff in it. So for example, if we have Y ->
-- foo and we want to insert X -> Y, we notice that, in
-- fact, Y has already been replaced by foo, so we add
-- X -> foo instead
--
-- Note that it is undefined if you try to append something like Y
-- -> foo to Y -> bar, because that would mean that
-- unification is broken
prependToSubst :: (String, GeniVal) -> Subst -> Subst
data UnificationResult
SuccessSans :: GeniVal -> UnificationResult
SuccessRep :: String -> GeniVal -> UnificationResult
Failure :: UnificationResult
-- | See source code for details
unifyOne :: GeniVal -> GeniVal -> UnificationResult
replace :: (DescendGeniVal a) => Subst -> a -> a
replaceOne :: (DescendGeniVal a) => (String, GeniVal) -> a -> a
-- | Here it is safe to say (X -> Y; Y -> Z) because this would be
-- crushed down into a final value of (X -> Z; Y -> Z)
replaceList :: (DescendGeniVal a) => [(String, GeniVal)] -> a -> a
replaceMapG :: Subst -> GeniVal -> GeniVal
replaceOneG :: (String, GeniVal) -> GeniVal -> GeniVal
class DescendGeniVal a
descendGeniVal :: (DescendGeniVal a) => (GeniVal -> GeniVal) -> a -> a
-- | Unifying something with itself should always succeed
prop_unify_self :: [GeniVal] -> Property
-- | Unifying something with only anonymous variables should succeed and
-- return the same result.
prop_unify_anon :: [GeniVal] -> Bool
-- | Unification should be symmetrical. We can't guarantee these if there
-- are cases where there are variables in the same place on both sides,
-- so we normalise the sides so that this doesn't happen.
prop_unify_sym :: [GeniVal] -> [GeniVal] -> Property
newtype GTestString
GTestString :: String -> GTestString
newtype GTestString2
GTestString2 :: String -> GTestString2
fromGTestString :: GTestString -> String
fromGTestString2 :: GTestString2 -> String
qc_not_empty_GConst :: GeniVal -> Bool
instance [overlap ok] Typeable GeniVal
instance [overlap ok] Eq GeniVal
instance [overlap ok] Ord GeniVal
instance [overlap ok] Data GeniVal
instance [overlap ok] Arbitrary GeniVal
instance [overlap ok] Arbitrary GTestString2
instance [overlap ok] Arbitrary GTestString
instance [overlap ok] (Functor f, DescendGeniVal a) => DescendGeniVal (f a)
instance [overlap ok] DescendGeniVal GeniVal
instance [overlap ok] NFData GeniVal
instance [overlap ok] Show GeniVal
instance [overlap ok] Uniplate GeniVal
-- | This module provides a simple, naive implementation of
-- nondeterministic finite automata (NFA).
--
-- The transition function consists of a Map, but there are also accessor
-- function which help you query the automaton without worrying about how
-- it's implemented.
--
-- 1. The states are a list of lists, not just a simple flat list as you
-- might expect. This allows you to optionally group your states into
-- "columns" which is something we use in the GenI polarity automaton
-- optimisation.
--
-- 2. We model the empty an empty transition as the transition on
-- Nothing. All other transitions are Just something.
module NLP.GenI.Automaton
-- | Note: you can define the final state either by setting
-- isFinalSt to Just f where f is some function
-- or by putting them in finalStList
data NFA st ab
NFA :: st -> Maybe (st -> Bool) -> [st] -> Map st (Map st [Maybe ab]) -> [[st]] -> NFA st ab
startSt :: NFA st ab -> st
-- | finalSt will use this if defined
isFinalSt :: NFA st ab -> Maybe (st -> Bool)
-- | can be ignored if isFinalSt is defined
finalStList :: NFA st ab -> [st]
-- | there can be more than one transition between any two states and a
-- transition could be the empty symbol
transitions :: NFA st ab -> Map st (Map st [Maybe ab])
-- | if you don't care about grouping states into columns you can just dump
-- everything in one big list
states :: NFA st ab -> [[st]]
-- | finalSt returns all the final states of an automaton
finalSt :: NFA st ab -> [st]
addTrans :: (Ord ab, Ord st) => NFA st ab -> st -> Maybe ab -> st -> NFA st ab
-- | lookupTrans aut st1 ab returns the states that
-- st1 transitions to via a.
lookupTrans :: (Ord ab, Ord st) => NFA st ab -> st -> (Maybe ab) -> [st]
-- | Returns all possible paths through an automaton from the start state
-- to any dead-end.
--
-- Each path is represented as a list of labels.
--
-- We assume that the automaton does not have any loops in it.
automatonPaths :: (Ord st, Ord ab) => (NFA st ab) -> [[ab]]
-- | The set of all bundled paths. A bundled path is a sequence of states
-- through the automaton from the start state to any dead end. Any two
-- neighbouring states can have more than one possible transition between
-- them, so the bundles can multiply out to a lot of different possible
-- paths.
--
-- The output is a list of lists of lists:
--
--
-- - Each item in the outer list is a bundled path through the
-- automaton, i.e. without distinguishing between the possible
-- transitions from any two neighbouring states
-- - Each item in the middle list is represents the set of transitions
-- between two given neighbouring states
-- - Each item in the inner list represents a transition between two
-- given states
--
automatonPathSets :: (Ord st, Ord ab) => (NFA st ab) -> [[[ab]]]
numStates :: NFA st ab -> Int
numTransitions :: NFA st ab -> Int
module NLP.GenI.Btypes
-- | A single node of a TAG tree.
data GNode
GN :: NodeName -> Flist -> Flist -> Bool -> [String] -> GType -> Bool -> String -> GNode
gnname :: GNode -> NodeName
-- | top feature structure
gup :: GNode -> Flist
-- | bottom feature structure
gdown :: GNode -> Flist
-- | False for na nodes
ganchor :: GNode -> Bool
-- | [] for na nodes
glexeme :: GNode -> [String]
gtype :: GNode -> GType
gaconstr :: GNode -> Bool
-- | for TAG, this would be the elementary tree that this node originally
-- came from
gorigin :: GNode -> String
data GType
Subs :: GType
Foot :: GType
Lex :: GType
Other :: GType
type NodeName = String
data Ttree a
TT :: [GeniVal] -> String -> String -> Flist -> Ptype -> Maybe Sem -> [String] -> Tree a -> Ttree a
params :: Ttree a -> [GeniVal]
pfamily :: Ttree a -> String
pidname :: Ttree a -> String
pinterface :: Ttree a -> Flist
ptype :: Ttree a -> Ptype
psemantics :: Ttree a -> Maybe Sem
ptrace :: Ttree a -> [String]
tree :: Ttree a -> Tree a
type MTtree = Ttree GNode
type SemPols = [Int]
data TestCase
TestCase :: String -> String -> SemInput -> [String] -> [(String, Map (String, String) [String])] -> TestCase
tcName :: TestCase -> String
-- | for gui
tcSemString :: TestCase -> String
tcSem :: TestCase -> SemInput
-- | expected results (for testing)
tcExpected :: TestCase -> [String]
-- | results we actually got, and their traces (for testing)
tcOutputs :: TestCase -> [(String, Map (String, String) [String])]
data Ptype
Initial :: Ptype
Auxiliar :: Ptype
Unspecified :: Ptype
type Pred = (GeniVal, GeniVal, [GeniVal])
type Flist = [AvPair]
data AvPair
AvPair :: String -> GeniVal -> AvPair
avAtt :: AvPair -> String
avVal :: AvPair -> GeniVal
data GeniVal
-- | atomic disjunction - constant x | y | z
GConst :: [String] -> GeniVal
-- | variable
GVar :: String -> GeniVal
-- | anonymous
GAnon :: GeniVal
-- | A lexicon maps semantic predicates to lexical entries.
type Lexicon = Map String [ILexEntry]
data ILexEntry
ILE :: [String] -> String -> [GeniVal] -> Flist -> Flist -> Flist -> Ptype -> Sem -> [SemPols] -> ILexEntry
iword :: ILexEntry -> [String]
ifamname :: ILexEntry -> String
iparams :: ILexEntry -> [GeniVal]
iinterface :: ILexEntry -> Flist
ifilters :: ILexEntry -> Flist
iequations :: ILexEntry -> Flist
iptype :: ILexEntry -> Ptype
isemantics :: ILexEntry -> Sem
isempols :: ILexEntry -> [SemPols]
type MorphLexEntry = (String, String, Flist)
type Macros = [MTtree]
type Sem = [Pred]
type LitConstr = (Pred, [String])
type SemInput = (Sem, Flist, [LitConstr])
type Subst = Map String GeniVal
emptyLE :: ILexEntry
-- | A null GNode which you can use for various debugging or display
-- purposes.
emptyGNode :: GNode
-- | A null tree which you can use for various debugging or display
-- purposes.
emptyMacro :: MTtree
-- | Return the value of the cat attribute, if available
gCategory :: Flist -> Maybe GeniVal
showLexeme :: [String] -> String
-- | Attributes recognised as lexemes, in order of preference
lexemeAttributes :: [String]
gnnameIs :: NodeName -> GNode -> Bool
-- | 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!
plugTree :: Tree NodeName -> NodeName -> Tree NodeName -> Tree NodeName
-- | Given two trees auxt and t, splice the tree auxt into t via the TAG
-- adjunction rule.
spliceTree :: NodeName -> Tree NodeName -> NodeName -> Tree NodeName -> Tree NodeName
root :: Tree a -> a
rootUpd :: Tree a -> a -> Tree a
foot :: Tree GNode -> GNode
-- | Given a lexical item l and a tree node n (actually a
-- subtree with no children), return the same node with the lexical item
-- as its unique child. The idea is that it converts terminal lexeme
-- nodes into preterminal nodes where the actual terminal is the given
-- lexical item
setLexeme :: [String] -> Tree GNode -> Tree GNode
-- | Given a lexical item s and a Tree GNode t, returns the tree
-- t' where l has been assigned to the anchor node in t'
setAnchor :: [String] -> Tree GNode -> Tree GNode
-- | Given a Semantics, return the string with the proper keys
-- (propsymbol+arity) to access the agenda
toKeys :: Sem -> [String]
subsumeSem :: Sem -> Sem -> [(Sem, Subst)]
-- | Sort semantics first according to its predicate, and then to its
-- handles.
sortSem :: Sem -> Sem
showSem :: Sem -> String
showPred :: Pred -> String
emptyPred :: Pred
-- | Sort an Flist according with its attributes
sortFlist :: Flist -> Flist
-- | unify performs unification on two lists of GeniVal. If
-- unification succeeds, it returns Just (r,s) where verb!r! is
-- the result of unification and verb!s! is a list of substitutions that
-- this unification results in.
unify :: (Monad m) => [GeniVal] -> [GeniVal] -> m ([GeniVal], Subst)
-- | unifyFeat performs feature structure unification, under the
-- these assumptions about the input:
--
--
-- - Features are ordered
-- - The Flists do not share variables (renaming has already been
-- done.
--
--
-- The features are allowed to have different sets of attributes, beacuse
-- we use alignFeat to realign them.
unifyFeat :: (Monad m) => Flist -> Flist -> m (Flist, Subst)
-- | Note that the first Subst is assumed to come chronologically before
-- the second one; so merging { X -> Y } and { Y -> 3
-- } should give us { X -> 3; Y -> 3 };
--
-- See prependToSubst for a warning!
mergeSubst :: Subst -> Subst -> Subst
showFlist :: Flist -> String
showPairs :: Flist -> String
showAv :: AvPair -> String
replace :: (DescendGeniVal a) => Subst -> a -> a
class DescendGeniVal a
descendGeniVal :: (DescendGeniVal a) => (GeniVal -> GeniVal) -> a -> a
-- | Here it is safe to say (X -> Y; Y -> Z) because this would be
-- crushed down into a final value of (X -> Z; Y -> Z)
replaceList :: (DescendGeniVal a) => [(String, GeniVal)] -> a -> a
class Collectable a
collect :: (Collectable a) => a -> Set String -> Set String
-- | An Idable is something that can be mapped to a unique id. You might
-- consider using this to implement Ord, but I won't. Note that the only
-- use I have for this so far (20 dec 2005) is in alpha-conversion.
class Idable a
idOf :: (Idable a) => a -> Integer
alphaConvert :: (Collectable a, DescendGeniVal a) => String -> a -> a
alphaConvertById :: (Collectable a, DescendGeniVal a, Idable a) => a -> a
-- | (assumes that it's a GConst!)
fromGConst :: GeniVal -> [String]
-- | (assumes that it's a GVar!)
fromGVar :: GeniVal -> String
isConst :: GeniVal -> Bool
isVar :: GeniVal -> Bool
isAnon :: GeniVal -> Bool
instance [overlap ok] Typeable AvPair
instance [overlap ok] Typeable GType
instance [overlap ok] Typeable GNode
instance [overlap ok] Typeable ILexEntry
instance [overlap ok] Typeable Ptype
instance [overlap ok] Typeable1 Ttree
instance [overlap ok] Show TestCase
instance [overlap ok] Ord AvPair
instance [overlap ok] Eq AvPair
instance [overlap ok] Data AvPair
instance [overlap ok] Show GType
instance [overlap ok] Eq GType
instance [overlap ok] Data GType
instance [overlap ok] Eq GNode
instance [overlap ok] Data GNode
instance [overlap ok] Show ILexEntry
instance [overlap ok] Eq ILexEntry
instance [overlap ok] Data ILexEntry
instance [overlap ok] Show Ptype
instance [overlap ok] Eq Ptype
instance [overlap ok] Data Ptype
instance [overlap ok] (Show a) => Show (Ttree a)
instance [overlap ok] (Data a) => Data (Ttree a)
instance [overlap ok] DescendGeniVal Pred
instance [overlap ok] Biplate (Maybe Sem) GeniVal
instance [overlap ok] Biplate Pred GeniVal
instance [overlap ok] Show AvPair
instance [overlap ok] DescendGeniVal ([String], Flist)
instance [overlap ok] (DescendGeniVal a) => DescendGeniVal (String, a)
instance [overlap ok] DescendGeniVal AvPair
instance [overlap ok] (DescendGeniVal a) => DescendGeniVal (Map k a)
instance [overlap ok] Collectable GNode
instance [overlap ok] Collectable AvPair
instance [overlap ok] Collectable GeniVal
instance [overlap ok] (Collectable a, Collectable b, Collectable c) => Collectable (a, b, c)
instance [overlap ok] (Collectable a) => Collectable (Tree a)
instance [overlap ok] (Collectable a) => Collectable [a]
instance [overlap ok] (Collectable a) => Collectable (Maybe a)
instance [overlap ok] Biplate AvPair GeniVal
instance [overlap ok] DescendGeniVal GNode
instance [overlap ok] Show GNode
instance [overlap ok] Biplate (Tree GNode) GeniVal
instance [overlap ok] Biplate GNode GeniVal
instance [overlap ok] Collectable ILexEntry
instance [overlap ok] DescendGeniVal ILexEntry
instance [overlap ok] Biplate ILexEntry GeniVal
instance [overlap ok] (Collectable a) => Collectable (Ttree a)
instance [overlap ok] DescendGeniVal (Ttree GNode)
instance [overlap ok] Biplate (Ttree GNode) GeniVal
instance [overlap ok] Biplate (Ttree String) GeniVal
module NLP.GenI.BtypesBinary
instance [overlap ok] Binary ILexEntry
instance [overlap ok] Binary AvPair
instance [overlap ok] (Binary a) => Binary (Ttree a)
instance [overlap ok] Binary GType
instance [overlap ok] Binary GNode
instance [overlap ok] Binary GeniVal
instance [overlap ok] Binary Ptype
module NLP.GenI.Tags
-- | An anchored grammar. The grammar associates a set of semantic
-- predicates to a list of trees each.
type Tags = Map String [TagElem]
data TagElem
TE :: String -> String -> Integer -> Ptype -> Tree GNode -> Sem -> Map PolarityKey (Int, Int) -> Flist -> [String] -> [SemPols] -> TagElem
idname :: TagElem -> String
ttreename :: TagElem -> String
tidnum :: TagElem -> Integer
ttype :: TagElem -> Ptype
ttree :: TagElem -> Tree GNode
tsemantics :: TagElem -> Sem
tpolarities :: TagElem -> Map PolarityKey (Int, Int)
tinterface :: TagElem -> Flist
ttrace :: TagElem -> [String]
tsempols :: TagElem -> [SemPols]
-- | TagItem is a generalisation of TagElem.
class TagItem t
tgIdName :: (TagItem t) => t -> String
tgIdNum :: (TagItem t) => t -> Integer
tgSemantics :: (TagItem t) => t -> Sem
data TagSite
TagSite :: String -> Flist -> Flist -> String -> TagSite
tsName :: TagSite -> String
tsUp :: TagSite -> Flist
tsDown :: TagSite -> Flist
tsOrigin :: TagSite -> String
type TagDerivation = [DerivationStep]
data DerivationStep
DerivationStep :: Char -> String -> String -> String -> DerivationStep
dsOp :: DerivationStep -> Char
dsChild :: DerivationStep -> String
dsParent :: DerivationStep -> String
dsParentSite :: DerivationStep -> String
emptyTE :: TagElem
ts_synIncomplete :: String
ts_semIncomplete :: [Pred] -> String
ts_tbUnificationFailure :: String
ts_rootFeatureMismatch :: Flist -> String
-- | addTags tags key elem adds elem to the the list of
-- elements associated to the key
addToTags :: Tags -> String -> TagElem -> Tags
tagLeaves :: TagElem -> [(String, UninflectedDisjunction)]
-- | Assigns a unique id to each element of this list, that is, an integer
-- between 1 and the size of the list.
setTidnums :: [TagElem] -> [TagElem]
-- | 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.
mapBySem :: (TagItem t) => [t] -> Map Pred [t]
-- | subsumedBy cs ts determines if the candidate semantics
-- cs is subsumed by the proposition semantics ts.
-- Notice how the proposition semantics is only a single item where as
-- the candidate semantics is a list.
--
-- We assume
--
--
-- - most importantly that cs has already its semantics
-- instatiated (all variables assigned)
-- - cs and ts are sorted
-- - the list in each element of cs and ts is itself sorted
--
subsumedBy :: Sem -> Pred -> Bool
showTagSites :: [TagSite] -> String
collect :: (Collectable a) => a -> Set String -> Set String
-- | Given a tree(GNode) returns a list of substitution or adjunction
-- nodes, as well as remaining nodes with a null adjunction constraint.
detectSites :: Tree GNode -> ([TagSite], [TagSite], [TagSite])
instance [overlap ok] Typeable TagElem
instance [overlap ok] Typeable TagSite
instance [overlap ok] Show DerivationStep
instance [overlap ok] Ord DerivationStep
instance [overlap ok] Eq DerivationStep
instance [overlap ok] Show TagElem
instance [overlap ok] Eq TagElem
instance [overlap ok] Data TagElem
instance [overlap ok] Show TagSite
instance [overlap ok] Eq TagSite
instance [overlap ok] Ord TagSite
instance [overlap ok] Data TagSite
instance [overlap ok] TagItem TagElem
instance [overlap ok] Idable TagElem
instance [overlap ok] Collectable TagElem
instance [overlap ok] DescendGeniVal TagSite
instance [overlap ok] DescendGeniVal TagElem
instance [overlap ok] Ord TagElem
instance [overlap ok] JSON DerivationStep
instance [overlap ok] Biplate TagElem GeniVal
instance [overlap ok] Biplate (Maybe TagSite) GeniVal
instance [overlap ok] Biplate TagSite GeniVal
module NLP.GenI.GeniShow
class GeniShow a
geniShow :: (GeniShow a) => a -> String
squares :: String -> String
parens :: String -> String
geniShowKeyword :: String -> ShowS
geniShowSemInput :: SemInput -> ShowS
instance [overlap ok] GeniShow TestCase
instance [overlap ok] (GeniShow a) => GeniShow (Ttree a)
instance [overlap ok] GeniShow TagElem
instance [overlap ok] (GeniShow a) => GeniShow (Tree a)
instance [overlap ok] (GeniShow a) => GeniShow [a]
instance [overlap ok] GeniShow GNode
instance [overlap ok] GeniShow Pred
instance [overlap ok] GeniShow GeniVal
instance [overlap ok] GeniShow AvPair
instance [overlap ok] GeniShow Ptype
module NLP.GenI.GeniParsers
geniTestSuite :: Parser [TestCase]
geniSemanticInput :: Parser (Sem, Flist, [LitConstr])
-- | Just the String representations of the semantics in the test suite
geniTestSuiteString :: Parser [String]
-- | This is only used by the script genimakesuite
geniDerivations :: Parser [TestCaseOutput]
toSemInputString :: SemInput -> String -> SemInputString
geniMacros :: Parser [MTtree]
-- | This makes it possible to read anchored trees, which may be useful for
-- debugging purposes.
--
-- FIXME: note that this is very rudimentary; we do not set id numbers,
-- parse polarities. You'll have to call some of our helper functions if
-- you want that functionality.
geniTagElems :: Parser [TagElem]
geniLexicon :: Parser [ILexEntry]
geniMorphInfo :: Parser [(String, Flist)]
geniFeats :: Parser Flist
geniPolarities :: Parser (Map PolarityKey Interval)
geniSemantics :: Parser Sem
geniValue :: Parser GeniVal
geniWords :: Parser String
geniWord :: Parser String
geniLanguageDef :: LanguageDef ()
tillEof :: Parser a -> Parser a
parseFromFile :: Parser a -> SourceName -> IO (Either ParseError a)
instance [overlap ok] GeniShow SemInputString
module NLP.GenI.Polarity
type PolAut = NFA PolState PolTrans
data PolState
-- | position in the input semantics, extra semantics, polarity interval
PolSt :: Int -> [Pred] -> [(Int, Int)] -> PolState
type AutDebug = (PolarityKey, PolAut, PolAut)
-- | intermediate auts, seed aut, final aut, potentially modified sem
type PolResult = ([AutDebug], PolAut, PolAut, Sem)
-- | Constructs a polarity automaton. For debugging purposes, it returns
-- all the intermediate automata produced by the construction algorithm.
buildAutomaton :: Set PolarityAttr -> Flist -> PolMap -> SemInput -> [TagElem] -> PolResult
makePolAut :: [TagElem] -> Sem -> PolMap -> PolResult
-- | Returns a modified input semantics and lexical selection in which
-- pronouns are properly accounted for.
fixPronouns :: (Sem, [TagElem]) -> (Sem, [TagElem])
detectSansIdx :: [TagElem] -> [TagElem]
detectPolFeatures :: [TagElem] -> [String]
detectPols :: Set PolarityAttr -> [TagElem] -> [TagElem]
-- | Given a list of paths (i.e. a list of list of trees) return a list of
-- trees such that each tree is annotated with the paths it belongs to.
detectPolPaths :: [[TagElem]] -> [(TagElem, BitVector)]
declareIdxConstraints :: Flist -> PolMap
detectIdxConstraints :: Flist -> Flist -> PolMap
showLite :: (ShowLite a) => a -> String
-- | Display a PolMap in human-friendly text. The advantage is that it
-- displays fewer quotation marks.
showLitePm :: PolMap -> String
-- | Render the list of polarity automaton paths as a string
showPolPaths :: BitVector -> String
showPolPaths' :: BitVector -> Int -> [Int]
-- | Returns all possible paths through an automaton from the start state
-- to any dead-end.
--
-- Each path is represented as a list of labels.
--
-- We assume that the automaton does not have any loops in it.
automatonPaths :: (Ord st, Ord ab) => (NFA st ab) -> [[ab]]
-- | finalSt returns all the final states of an automaton
finalSt :: NFA st ab -> [st]
-- | Note: you can define the final state either by setting
-- isFinalSt to Just f where f is some function
-- or by putting them in finalStList
data NFA st ab
instance [overlap ok] Eq PolState
instance [overlap ok] ShowLite TagElem
instance [overlap ok] ShowLite Char
instance [overlap ok] ShowLite Int
instance [overlap ok] (ShowLite a, ShowLite b) => ShowLite (a, b)
instance [overlap ok] (ShowLite a) => ShowLite [a]
instance [overlap ok] Ord PolState
instance [overlap ok] Show PolState
module NLP.GenI.Configuration
-- | Holds the specification for how Geni should be run, its input files,
-- etc. This is the stuff that would normally be found in the
-- configuration file.
data Params
Prms :: GrammarType -> BuilderType -> [Flag] -> Params
grammarType :: Params -> GrammarType
builderType :: Params -> BuilderType
geniFlags :: Params -> [Flag]
data GrammarType
-- | geni's text format
GeniHand :: GrammarType
-- | built into geni, no parsing needed
PreCompiled :: GrammarType
-- | lexical selection already done
PreAnchored :: GrammarType
data BuilderType
NullBuilder :: BuilderType
SimpleBuilder :: BuilderType
SimpleOnePhaseBuilder :: BuilderType
type Instruction = (FilePath, Maybe [String])
data Flag
data BatchDirFlg
BatchDirFlg :: FilePath -> BatchDirFlg
data DetectPolaritiesFlg
DetectPolaritiesFlg :: (Set PolarityAttr) -> DetectPolaritiesFlg
data DisableGuiFlg
DisableGuiFlg :: () -> DisableGuiFlg
data DumpDerivationFlg
DumpDerivationFlg :: () -> DumpDerivationFlg
data EarlyDeathFlg
EarlyDeathFlg :: () -> EarlyDeathFlg
data ExtraPolaritiesFlg
ExtraPolaritiesFlg :: (Map PolarityKey Interval) -> ExtraPolaritiesFlg
data FromStdinFlg
FromStdinFlg :: () -> FromStdinFlg
data HelpFlg
HelpFlg :: () -> HelpFlg
data InstructionsFileFlg
InstructionsFileFlg :: FilePath -> InstructionsFileFlg
data LexiconFlg
LexiconFlg :: FilePath -> LexiconFlg
data MacrosFlg
MacrosFlg :: FilePath -> MacrosFlg
data MetricsFlg
MetricsFlg :: [String] -> MetricsFlg
data MorphCmdFlg
MorphCmdFlg :: String -> MorphCmdFlg
data MorphInfoFlg
MorphInfoFlg :: FilePath -> MorphInfoFlg
data NoLoadTestSuiteFlg
NoLoadTestSuiteFlg :: () -> NoLoadTestSuiteFlg
data OptimisationsFlg
OptimisationsFlg :: [Optimisation] -> OptimisationsFlg
data OutputFileFlg
OutputFileFlg :: String -> OutputFileFlg
data PartialFlg
PartialFlg :: () -> PartialFlg
data RankingConstraintsFlg
RankingConstraintsFlg :: FilePath -> RankingConstraintsFlg
data RegressionTestModeFlg
RegressionTestModeFlg :: () -> RegressionTestModeFlg
data RootFeatureFlg
RootFeatureFlg :: Flist -> RootFeatureFlg
data RunUnitTestFlg
RunUnitTestFlg :: () -> RunUnitTestFlg
data StatsFileFlg
StatsFileFlg :: FilePath -> StatsFileFlg
data TestCaseFlg
TestCaseFlg :: String -> TestCaseFlg
data TestInstructionsFlg
TestInstructionsFlg :: [Instruction] -> TestInstructionsFlg
data TestSuiteFlg
TestSuiteFlg :: FilePath -> TestSuiteFlg
data TimeoutFlg
TimeoutFlg :: Integer -> TimeoutFlg
data TracesFlg
TracesFlg :: FilePath -> TracesFlg
data VerboseModeFlg
VerboseModeFlg :: () -> VerboseModeFlg
data VersionFlg
VersionFlg :: () -> VersionFlg
data ViewCmdFlg
ViewCmdFlg :: String -> ViewCmdFlg
mainBuilderTypes :: [BuilderType]
getFlagP :: (Show f, Show x, Typeable f, Typeable x) => (x -> f) -> Params -> Maybe x
getListFlagP :: (Show f, Show x, Typeable f, Typeable x) => ([x] -> f) -> Params -> [x]
setFlagP :: (Eq f, Show f, Show x, Typeable f, Typeable x) => (x -> f) -> x -> Params -> Params
hasFlagP :: (Typeable f, Typeable x) => (x -> f) -> Params -> Bool
deleteFlagP :: (Typeable f, Typeable x) => (x -> f) -> Params -> Params
hasOpt :: Optimisation -> Params -> Bool
getFlag :: (Show f, Show x, Typeable f, Typeable x) => (x -> f) -> [Flag] -> Maybe x
setFlag :: (Eq f, Show f, Show x, Typeable f, Typeable x) => (x -> f) -> x -> [Flag] -> [Flag]
hasFlag :: (Typeable f, Typeable x) => (x -> f) -> [Flag] -> Bool
data Optimisation
PolOpts :: Optimisation
AdjOpts :: Optimisation
Polarised :: Optimisation
NoConstraints :: Optimisation
SemFiltered :: Optimisation
-- | one phase only!
Iaf :: Optimisation
EarlyNa :: Optimisation
-- | The default parameters configuration
emptyParams :: Params
defineParams :: [Flag] -> Params -> Params
treatArgs :: [OptDescr Flag] -> [String] -> IO Params
treatArgsWithParams :: [OptDescr Flag] -> [String] -> Params -> IO Params
-- | Print out a GenI-style usage message with options divided into
-- sections
usage :: [OptSection] -> String -> String
basicSections :: [OptSection]
optionsSections :: [OptSection]
-- | Update the internal instructions list, test suite and case according
-- to the contents of an instructions file.
processInstructions :: Params -> IO Params
-- | Uses the GetOpt library to process the command line arguments. Note
-- that we divide them into basic and advanced usage.
optionsForStandardGenI :: [OptDescr Flag]
optionsForBasicStuff :: [OptDescr Flag]
optionsForOptimisation :: [OptDescr Flag]
optionsForMorphology :: [OptDescr Flag]
optionsForInputFiles :: [OptDescr Flag]
optionsForBuilder :: [OptDescr Flag]
optionsForTesting :: [OptDescr Flag]
nubBySwitches :: [OptDescr a] -> [OptDescr a]
noArg :: (Eq f, Show f, Typeable f) => (() -> f) -> ArgDescr Flag
reqArg :: (Eq f, Show f, Typeable f, Eq x, Show x, Typeable x) => (x -> f) -> (String -> x) -> String -> ArgDescr Flag
optArg :: (Eq f, Show f, Typeable f, Eq x, Show x, Typeable x) => (x -> f) -> x -> (String -> x) -> String -> ArgDescr Flag
parseFlagWithParsec :: String -> CharParser () b -> String -> b
-- | The class Typeable allows a concrete representation of a type
-- to be calculated.
class Typeable a
instance [overlap ok] Typeable WeirdFlg
instance [overlap ok] Typeable GrammarTypeFlg
instance [overlap ok] Typeable BuilderFlg
instance [overlap ok] Typeable ViewCmdFlg
instance [overlap ok] Typeable VersionFlg
instance [overlap ok] Typeable VerboseModeFlg
instance [overlap ok] Typeable TimeoutFlg
instance [overlap ok] Typeable TestSuiteFlg
instance [overlap ok] Typeable TestInstructionsFlg
instance [overlap ok] Typeable TestCaseFlg
instance [overlap ok] Typeable StatsFileFlg
instance [overlap ok] Typeable NoLoadTestSuiteFlg
instance [overlap ok] Typeable RunUnitTestFlg
instance [overlap ok] Typeable RootFeatureFlg
instance [overlap ok] Typeable RegressionTestModeFlg
instance [overlap ok] Typeable RankingConstraintsFlg
instance [overlap ok] Typeable PartialFlg
instance [overlap ok] Typeable OutputFileFlg
instance [overlap ok] Typeable OptimisationsFlg
instance [overlap ok] Typeable MorphInfoFlg
instance [overlap ok] Typeable MorphCmdFlg
instance [overlap ok] Typeable MetricsFlg
instance [overlap ok] Typeable TracesFlg
instance [overlap ok] Typeable MacrosFlg
instance [overlap ok] Typeable LexiconFlg
instance [overlap ok] Typeable InstructionsFileFlg
instance [overlap ok] Typeable HelpFlg
instance [overlap ok] Typeable FromStdinFlg
instance [overlap ok] Typeable ExtraPolaritiesFlg
instance [overlap ok] Typeable EarlyDeathFlg
instance [overlap ok] Typeable DumpDerivationFlg
instance [overlap ok] Typeable DetectPolaritiesFlg
instance [overlap ok] Typeable DisableGuiFlg
instance [overlap ok] Typeable BatchDirFlg
instance [overlap ok] Typeable Flag
instance [overlap ok] Typeable GrammarType
instance [overlap ok] Typeable BuilderType
instance [overlap ok] Typeable Optimisation
instance [overlap ok] Eq WeirdFlg
instance [overlap ok] Show WeirdFlg
instance [overlap ok] Eq GrammarTypeFlg
instance [overlap ok] Show GrammarTypeFlg
instance [overlap ok] Eq BuilderFlg
instance [overlap ok] Show BuilderFlg
instance [overlap ok] Eq ViewCmdFlg
instance [overlap ok] Show ViewCmdFlg
instance [overlap ok] Eq VersionFlg
instance [overlap ok] Show VersionFlg
instance [overlap ok] Eq VerboseModeFlg
instance [overlap ok] Show VerboseModeFlg
instance [overlap ok] Eq TimeoutFlg
instance [overlap ok] Show TimeoutFlg
instance [overlap ok] Eq TestSuiteFlg
instance [overlap ok] Show TestSuiteFlg
instance [overlap ok] Eq TestInstructionsFlg
instance [overlap ok] Show TestInstructionsFlg
instance [overlap ok] Eq TestCaseFlg
instance [overlap ok] Show TestCaseFlg
instance [overlap ok] Eq StatsFileFlg
instance [overlap ok] Show StatsFileFlg
instance [overlap ok] Eq NoLoadTestSuiteFlg
instance [overlap ok] Show NoLoadTestSuiteFlg
instance [overlap ok] Eq RunUnitTestFlg
instance [overlap ok] Show RunUnitTestFlg
instance [overlap ok] Eq RootFeatureFlg
instance [overlap ok] Show RootFeatureFlg
instance [overlap ok] Eq RegressionTestModeFlg
instance [overlap ok] Show RegressionTestModeFlg
instance [overlap ok] Eq RankingConstraintsFlg
instance [overlap ok] Show RankingConstraintsFlg
instance [overlap ok] Eq PartialFlg
instance [overlap ok] Show PartialFlg
instance [overlap ok] Eq OutputFileFlg
instance [overlap ok] Show OutputFileFlg
instance [overlap ok] Eq OptimisationsFlg
instance [overlap ok] Show OptimisationsFlg
instance [overlap ok] Eq MorphInfoFlg
instance [overlap ok] Show MorphInfoFlg
instance [overlap ok] Eq MorphCmdFlg
instance [overlap ok] Show MorphCmdFlg
instance [overlap ok] Eq MetricsFlg
instance [overlap ok] Show MetricsFlg
instance [overlap ok] Eq TracesFlg
instance [overlap ok] Show TracesFlg
instance [overlap ok] Eq MacrosFlg
instance [overlap ok] Show MacrosFlg
instance [overlap ok] Eq LexiconFlg
instance [overlap ok] Show LexiconFlg
instance [overlap ok] Eq InstructionsFileFlg
instance [overlap ok] Show InstructionsFileFlg
instance [overlap ok] Eq HelpFlg
instance [overlap ok] Show HelpFlg
instance [overlap ok] Eq FromStdinFlg
instance [overlap ok] Show FromStdinFlg
instance [overlap ok] Eq ExtraPolaritiesFlg
instance [overlap ok] Show ExtraPolaritiesFlg
instance [overlap ok] Eq EarlyDeathFlg
instance [overlap ok] Show EarlyDeathFlg
instance [overlap ok] Eq DumpDerivationFlg
instance [overlap ok] Show DumpDerivationFlg
instance [overlap ok] Eq DetectPolaritiesFlg
instance [overlap ok] Show DetectPolaritiesFlg
instance [overlap ok] Eq DisableGuiFlg
instance [overlap ok] Show DisableGuiFlg
instance [overlap ok] Eq BatchDirFlg
instance [overlap ok] Show BatchDirFlg
instance [overlap ok] Show GrammarType
instance [overlap ok] Eq GrammarType
instance [overlap ok] Eq BuilderType
instance [overlap ok] Show Optimisation
instance [overlap ok] Eq Optimisation
instance [overlap ok] Show Params
instance [overlap ok] Eq Flag
instance [overlap ok] Show Flag
instance [overlap ok] Show BuilderType
module NLP.GenI.Builder
data Builder st it pa
Builder :: (Input -> pa -> (st, Statistics)) -> BuilderState st () -> BuilderState st () -> (st -> Bool) -> (st -> [Output]) -> (st -> [Output]) -> Builder st it pa
init :: Builder st it pa -> Input -> pa -> (st, Statistics)
step :: Builder st it pa -> BuilderState st ()
stepAll :: Builder st it pa -> BuilderState st ()
finished :: Builder st it pa -> st -> Bool
unpack :: Builder st it pa -> st -> [Output]
partial :: Builder st it pa -> st -> [Output]
type Output = (LemmaPlusSentence, Derivation)
type Derivation = TagDerivation
data Input
Input :: SemInput -> [ILexEntry] -> [(TagElem, BitVector)] -> Input
inSemInput :: Input -> SemInput
-- | for the debugger
inLex :: Input -> [ILexEntry]
-- | tag tree
inCands :: Input -> [(TagElem, BitVector)]
type SentenceAut = NFA Int LemmaPlus
data UninflectedDisjunction
UninflectedDisjunction :: [String] -> Flist -> UninflectedDisjunction
type BuilderState s a = StateT s (State Statistics) a
preInit :: Input -> Params -> (Input, (Int, Int, Int), PolResult)
-- | Equivalent to id unless the input contains an empty or
-- uninstatiated semantics
unlessEmptySem :: Input -> Params -> a -> a
-- | 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
--
run :: Builder st it Params -> Input -> Params -> (st, Statistics)
type SemBitMap = Map Pred BitVector
-- | 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
defineSemanticBits :: Sem -> SemBitMap
semToBitVector :: SemBitMap -> Sem -> BitVector
bitVectorToSem :: SemBitMap -> BitVector -> Sem
type IafMap = Map String Sem
-- | Return the literals of the semantics (in bit vector form) whose
-- accesibility depends on the given index
dependentSem :: IafMap -> String -> Sem
-- | Return the handle and arguments of a literal
literalArgs :: Pred -> [GeniVal]
semToIafMap :: Sem -> IafMap
-- | Like fromGConst but only for the non-disjoint ones: meant to be used
-- as Maybe or List
fromUniConst :: (Monad m) => GeniVal -> m String
getIdx :: Flist -> [GeniVal]
ts_iafFailure :: [String] -> [Pred] -> String
-- | Calculate the new set of accessibility/inaccesible indices, returning
-- a a tuple of accesible / inaccesible indices
recalculateAccesibility :: (IafAble a) => a -> a
-- | Return, in bitvector form, the portion of a semantics that is
-- inaccesible from an item
iafBadSem :: (IafAble a) => IafMap -> SemBitMap -> BitVector -> (a -> BitVector) -> a -> BitVector
class IafAble a
iafAcc :: (IafAble a) => a -> [String]
iafInacc :: (IafAble a) => a -> [String]
iafSetAcc :: (IafAble a) => [String] -> a -> a
iafSetInacc :: (IafAble a) => [String] -> a -> a
iafNewAcc :: (IafAble a) => a -> [String]
-- | Default implementation for the stepAll function in
-- Builder
defaultStepAll :: Builder st it pa -> BuilderState st ()
type DispatchFilter s a = a -> s (Maybe a)
-- | Sequence two dispatch filters.
(>-->) :: (Monad s) => DispatchFilter s a -> DispatchFilter s a -> DispatchFilter s a
-- | A filter that always fails (i.e. no filtering)
nullFilter :: (Monad s) => DispatchFilter s a
-- | If the item meets some condition, use the first filter, otherwise use
-- the second one.
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
-- | 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
--
initNullBuilder :: Input -> Params -> ((), Statistics)
-- | The names of lexically selected chart items used in a derivation
lexicalSelection :: Derivation -> [String]
-- | A lemma plus its morphological features
data LemmaPlus
LemmaPlus :: String -> Flist -> LemmaPlus
lpLemma :: LemmaPlus -> String
lpFeats :: LemmaPlus -> Flist
-- | A sentence composed of LemmaPlus instead of plain old words
type LemmaPlusSentence = [LemmaPlus]
parsecToJSON :: (Monad m) => String -> CharParser () b -> String -> m b
instance [overlap ok] Typeable UninflectedDisjunction
instance [overlap ok] Show LemmaPlus
instance [overlap ok] Eq LemmaPlus
instance [overlap ok] Ord LemmaPlus
instance [overlap ok] Show UninflectedDisjunction
instance [overlap ok] Data UninflectedDisjunction
instance [overlap ok] JSON LemmaPlus
instance [overlap ok] Collectable UninflectedDisjunction
instance [overlap ok] DescendGeniVal UninflectedDisjunction
instance [overlap ok] Biplate UninflectedDisjunction GeniVal
module NLP.GenI.Morphology
type MorphFn = Pred -> Maybe Flist
-- | A lemma plus its morphological features
data LemmaPlus
LemmaPlus :: String -> Flist -> LemmaPlus
lpLemma :: LemmaPlus -> String
lpFeats :: LemmaPlus -> Flist
-- | A sentence composed of LemmaPlus instead of plain old words
type LemmaPlusSentence = [LemmaPlus]
-- | Converts information from a morphological information file into GenI's
-- internal format.
readMorph :: [(String, [AvPair])] -> MorphFn
-- | Filters away from an input semantics any literals whose realisation is
-- strictly morphological. The first argument tells us helps identify the
-- morphological literals -- it associates literals with morphological
-- stuff; if it returns Nothing, then it is non-morphological
stripMorphSem :: MorphFn -> Sem -> Sem
-- | attachMorph morphfn sem cands does the bulk of the
-- morphological input processing. We use morphfn to determine
-- which literals in sem contain morphological information and
-- what information they contain. Then we attach this morphological
-- information to the relevant trees in cand. A tree is
-- considered relevant w.r.t to a morphological literal if its semantics
-- contains at least one literal whose first index is the same as the
-- first index of the morphological literal.
attachMorph :: MorphFn -> Sem -> [TagElem] -> [TagElem]
setMorphAnchor :: GNode -> Tree GNode -> Tree GNode
-- | Converts a list of uninflected sentences into inflected ones by
-- calling
inflectSentencesUsingCmd :: String -> [LemmaPlusSentence] -> IO [(LemmaPlusSentence, [String])]
-- | Extracts the lemmas from a list of uninflected sentences. This is used
-- when the morphological generator is unavailable, doesn't work, etc.
sansMorph :: LemmaPlusSentence -> [String]
module NLP.GenI.OptimalityTheory
data OtConstraint
-- | the trace must appear
PositiveC :: String -> OtConstraint
-- | the trace must NOT appear
NegativeC :: String -> OtConstraint
-- | these traces must not appear AT THE SAME TIME
NegativeConjC :: [String] -> OtConstraint
type OtRanking = [[OtConstraint]]
type GetTraces = String -> [String]
type OtResult x = (Int, x, [OtViolation])
data OtViolation
data RankedOtConstraint
RankedOtConstraint :: Int -> OtConstraint -> RankedOtConstraint
rankResults :: GetTraces -> (a -> Derivation) -> OtRanking -> [a] -> [OtResult a]
otWarnings :: Macros -> OtRanking -> [OtViolation] -> [String]
prettyViolations :: GetTraces -> Bool -> [OtViolation] -> String
prettyRank :: Int -> String
instance [overlap ok] Ord LexItem
instance [overlap ok] Eq LexItem
instance [overlap ok] Show LexItem
instance [overlap ok] Show OtViolation
instance [overlap ok] Eq OtViolation
instance [overlap ok] Ord OtViolation
instance [overlap ok] Eq RankedOtConstraint2
instance [overlap ok] Show RankedOtConstraint
instance [overlap ok] Eq RankedOtConstraint
instance [overlap ok] Show OtConstraint
instance [overlap ok] Eq OtConstraint
instance [overlap ok] JSON OtViolation
instance [overlap ok] JSON RankedOtConstraint
instance [overlap ok] JSON OtConstraint
instance [overlap ok] Ord RankedOtConstraint2
instance [overlap ok] Ord RankedOtConstraint
module NLP.GenI.Simple.SimpleBuilder
type Agenda = [SimpleItem]
type AuxAgenda = [SimpleItem]
type Chart = [SimpleItem]
data SimpleStatus
type SimpleState a = BuilderState SimpleStatus a
data SimpleItem
SimpleItem :: ChartId -> [TagSite] -> [TagSite] -> BitVector -> BitVector -> [String] -> [String] -> [(String, UninflectedDisjunction)] -> Tree String -> TagSite -> Maybe TagSite -> [TagSite] -> TagDerivation -> SimpleGuiItem -> SimpleItem
siId :: SimpleItem -> ChartId
siSubstnodes :: SimpleItem -> [TagSite]
siAdjnodes :: SimpleItem -> [TagSite]
siSemantics :: SimpleItem -> BitVector
siPolpaths :: SimpleItem -> BitVector
siAccesible :: SimpleItem -> [String]
siInaccessible :: SimpleItem -> [String]
-- | actually: a set of pre-terminals and their leaves
siLeaves :: SimpleItem -> [(String, UninflectedDisjunction)]
siDerived :: SimpleItem -> Tree String
siRoot :: SimpleItem -> TagSite
siFoot :: SimpleItem -> Maybe TagSite
siPendingTb :: SimpleItem -> [TagSite]
siDerivation :: SimpleItem -> TagDerivation
siGuiStuff :: SimpleItem -> SimpleGuiItem
simpleBuilder_1p :: SimpleBuilder
simpleBuilder_2p :: SimpleBuilder
simpleBuilder :: Bool -> SimpleBuilder
theAgenda :: SimpleStatus -> Agenda
theHoldingPen :: SimpleStatus -> AuxAgenda
theChart :: SimpleStatus -> Chart
theResults :: SimpleStatus -> [SimpleItem]
-- | Creates an initial SimpleStatus.
initSimpleBuilder :: Bool -> Input -> Params -> (SimpleStatus, Statistics)
addToAgenda :: SimpleItem -> SimpleState ()
addToChart :: SimpleItem -> SimpleState ()
genconfig :: SimpleStatus -> Params
-- | Things whose only use is within the graphical debugger
data SimpleGuiItem
SimpleGuiItem :: [String] -> [GNode] -> [String] -> Sem -> String -> SimpleGuiItem
-- | nodes to highlight
siHighlight :: SimpleGuiItem -> [String]
-- | actually a set if there are things wrong with this item, what?
siNodes :: SimpleGuiItem -> [GNode]
siDiagnostic :: SimpleGuiItem -> [String]
siFullSem :: SimpleGuiItem -> Sem
siIdname :: SimpleGuiItem -> String
theTrash :: SimpleStatus -> Trash
step :: SimpleStatus -> GenerationPhase
unpackResult :: SimpleItem -> [Output]
instance [overlap ok] Typeable SimpleGuiItem
instance [overlap ok] Show SimpleGuiItem
instance [overlap ok] Data SimpleGuiItem
instance [overlap ok] Show SimpleItem
instance [overlap ok] Show SimpleStatus
instance [overlap ok] Show GenerationPhase
instance [overlap ok] IafAble SimpleItem
instance [overlap ok] DescendGeniVal SimpleGuiItem
instance [overlap ok] DescendGeniVal SimpleItem
instance [overlap ok] Biplate SimpleGuiItem GeniVal
instance [overlap ok] DescendGeniVal (String, UninflectedDisjunction)
instance [overlap ok] Biplate (String, UninflectedDisjunction) GeniVal
instance [overlap ok] Biplate SimpleItem GeniVal
module NLP.GenI.Geni
data ProgState
ST :: Params -> Macros -> Lexicon -> MorphFn -> SemInput -> String -> [TestCase] -> OtRanking -> [String] -> [String] -> ProgState
-- | the current configuration being processed
pa :: ProgState -> Params
gr :: ProgState -> Macros
le :: ProgState -> Lexicon
morphinf :: ProgState -> MorphFn
ts :: ProgState -> SemInput
-- | names of test case to run
tcase :: ProgState -> String
-- | name, original string (for gui), sem
tsuite :: ProgState -> [TestCase]
-- | OT constraints (optional)
ranking :: ProgState -> OtRanking
-- | simplified traces (optional)
traces :: ProgState -> [String]
-- | any warnings accumulated during realisation (most recent first)
warnings :: ProgState -> [String]
type ProgStateRef = IORef ProgState
-- | The program state when you start GenI for the very first time
emptyProgState :: Params -> ProgState
-- | initGeni performs lexical selection and strips the input
-- semantics of any morpohological literals
initGeni :: ProgStateRef -> IO (Input)
-- | Returns a list of sentences, a set of Statistics, and the generator
-- state. The generator state is mostly useful for debugging via the
-- graphical interface. Note that we assumes that you have already loaded
-- in your grammar and parsed your input semantics.
runGeni :: ProgStateRef -> Builder st it Params -> IO ([GeniResult], Statistics, st)
runGeniWithSelector :: ProgStateRef -> Selector -> Builder st it Params -> IO ([GeniResult], Statistics, st)
data GeniResult
GeniResult :: LemmaPlusSentence -> [String] -> Derivation -> [GeniLexSel] -> Int -> [OtViolation] -> ResultType -> GeniResult
grLemmaSentence :: GeniResult -> LemmaPlusSentence
grRealisations :: GeniResult -> [String]
grDerivation :: GeniResult -> Derivation
grLexSelection :: GeniResult -> [GeniLexSel]
grRanking :: GeniResult -> Int
grViolations :: GeniResult -> [OtViolation]
grResultType :: GeniResult -> ResultType
data ResultType
CompleteResult :: ResultType
PartialResult :: ResultType
-- | No morphology! Pretend the lemma string is a sentence
lemmaSentenceString :: GeniResult -> String
prettyResult :: ProgState -> GeniResult -> String
-- | Show the sentences produced by the generator, in a relatively compact
-- form
showRealisations :: [String] -> String
-- | Convert a list of items into a list of tuples (a,b) where a is an item
-- in the list and b is the number of times a in occurs in the list.
groupAndCount :: (Eq a, Ord a) => [a] -> [(a, Int)]
-- | getTraces is most likely useful for grammars produced by a
-- metagrammar system. Given a tree name, we retrieve the `trace'
-- information from the grammar for all trees that have this name. We
-- assume the tree name was constructed by GenI; see the source code for
-- details.
getTraces :: ProgState -> String -> [String]
-- | Only used for instances of GenI where the grammar is compiled directly
-- into GenI.
type Selector = ProgStateRef -> IO ([TagElem], [ILexEntry])
loadEverything :: ProgStateRef -> IO ()
loadLexicon :: ProgStateRef -> IO ()
-- | The macros are stored as a hashing function in the monad.
loadGeniMacros :: ProgStateRef -> IO ()
-- | Stores the results in the tcase and tsuite fields
loadTestSuite :: ProgStateRef -> IO [TestCase]
-- | Updates program state the same way as loadTestSuite
loadTargetSemStr :: ProgStateRef -> String -> IO ()
loadRanking :: ProgStateRef -> IO ()
readRanking :: Bool -> FilePath -> IO OtRanking
-- | combine macros lex creates the Tags repository
-- combining lexical entries and un-anchored trees from the grammar. It
-- also unifies the parameters used to specialize un-anchored trees and
-- propagates additional features given in the ILexEntry.
combine :: Macros -> Lexicon -> Tags
-- | Select and returns the set of entries from the lexicon whose semantics
-- subsumes the input semantics.
chooseLexCand :: Lexicon -> Sem -> [ILexEntry]
instance [overlap ok] Ord ResultType
instance [overlap ok] Eq ResultType
instance [overlap ok] Ord GeniLexSel
instance [overlap ok] Eq GeniLexSel
instance [overlap ok] Ord GeniResult
instance [overlap ok] Eq GeniResult
instance [overlap ok] JSON GeniLexSel
instance [overlap ok] JSON ResultType
instance [overlap ok] JSON GeniResult
instance [overlap ok] Show LexCombineError
instance [overlap ok] Error LexCombineError