module Types where import RegExp type AmbiguityClass = [Patt String] -- a token is typically a word that has an ambiguity class -- associated to it. In particular, the ambiguity class is -- a set of POS tags. type UToken = String type Token = (String, AmbiguityClass) -- Relative position, relative a relative position :-), -- Annotate a position with a variable. type Pos = Int type Var = String -- The position is relative to the current token or -- relative to another token. For the later to make -- sense, the other token should be unbounded. data Position = Relative Pos | -- -1 Spanning Pos (Maybe Var) | -- t@(-1*) VarSpanning Var Pos (Maybe Var) | -- t2@t1-1* Reference Var Pos -- t-1 data Type a = Forced a | Member a | Disjunctive [a] data Patt a = P a [Patt a] | PW | PId a deriving (Eq,Show) type Unique = Bool type CI a = (Maybe Position, Maybe Reg, Maybe (Unique,Patt a)) type Context a = [CI a] data Boundary = None | Unlimited | BSize Int deriving (Eq, Show) type Name = String -- Paradigm Name type Head = [(RegExp,Maybe Constraint)] type VarEnv = [(String,RegExp)] data Logic a = Conj (Logic a) (Logic a) | Disj (Logic a) (Logic a) | Neg (Logic a) | Atom a type Constraint = Logic (CI String) type Body = Logic ((Reg,RegExp),Maybe Constraint) type Identifier = String -- to distinguish paradigm rules with the same paradigm identifier. type Paradigm = (Name, Identifier, Head, Body, VarEnv) type Paradigms = [Paradigm] type ITable = [(String,String)] -- instantiated variables type MatchedWordForms = [String] ------------------------------- name :: Paradigm -> Name name (n,_,_,_,_) = n ident :: Paradigm -> Identifier ident (_,i,_,_,_) = i head :: Paradigm -> Head head (_,_,h,_,_) = h body :: Paradigm -> Body body (_,_,_,b,_) = b varenv :: Paradigm -> VarEnv varenv (_,_,_,_,e) = e ------------------------------ -- Constraint Grammar -- a grammar is polymorphic over the ambiguity class type --newtype Grammar a b = Grammar [Constraint a b] -- We perform 'Action a' on 'b' if 'b':s context is LeftContext and -- RightContext --type Constraint a b = (Action a, b, Context a) --type Careful = Bool -- An action may apply on one or many items in the ambiguity class. --data AClass a = One a | Many [a] -- The difference to Carlsson's approach is that here -- we do not assume total knowledge. -- Force = replace ambiguity class with a -- Select = works only if 'a' is actually part of the ambiguity class -- SelectOrRemove = removes a if no match. -- Remove = remove a from ambiguity class -- Add = add a to ambiguity class --data Action a = Force (AClass a) | -- Select (AClass a) | -- SelectOrRemove Careful (AClass a) | -- Remove Careful (AClass a) | -- Add (AClass a)