Copyright | (c) 2017-20192023 Dakotah Lambert |
---|---|
License | MIT |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
This module provides a means to define positive and negative factors over the adjacency or precedence relations, as well as unions and intersections thereof.
Synopsis
- required :: Factor e -> Literal e
- forbidden :: Factor e -> Literal e
- buildLiteral :: (Enum n, Ord n, Ord e) => Set e -> Literal e -> FSA n e
- build :: (Enum n, NFData n, Ord n, NFData e, Ord e) => Set e -> Set (Conjunction e) -> FSA n e
- makeConstraint :: Ord e => [[Literal e]] -> Conjunction e
- data Factor e
- = Substring {
- substring :: [Set e]
- headAnchored :: Bool
- tailAnchored :: Bool
- | Subsequence [Set e]
- = Substring {
- data Literal e = Literal Bool (Factor e)
- newtype Disjunction e = Disjunction (Set (Literal e))
- newtype Conjunction e = Conjunction (Set (Disjunction e))
Constructions
required :: Factor e -> Literal e Source #
The factor is required to appear in every string.
Note that a conjunctive constraint of
(required (Substring x True True)
)
restricts the stringset to at most one word.
buildLiteral :: (Enum n, Ord n, Ord e) => Set e -> Literal e -> FSA n e Source #
Build an FSA
representing a single constraint.
build :: (Enum n, NFData n, Ord n, NFData e, Ord e) => Set e -> Set (Conjunction e) -> FSA n e Source #
Build an FSA
representing the conjunction of a set of
constraints provided in conjunctive normal form.
makeConstraint :: Ord e => [[Literal e]] -> Conjunction e Source #
Combine inner lists by Disjunction
,
and form a Conjunction
of the results.
Logical Expressions
A substring or subsequence, from which to build constraints.
Substring | |
| |
Subsequence [Set e] |
A constraint.
newtype Disjunction e Source #
Multiple constraints, joined by OR
.
Disjunction (Set (Literal e)) |
Instances
(Read e, Ord e) => Read (Disjunction e) Source # | |
Defined in LTK.Factors readsPrec :: Int -> ReadS (Disjunction e) # readList :: ReadS [Disjunction e] # readPrec :: ReadPrec (Disjunction e) # readListPrec :: ReadPrec [Disjunction e] # | |
Show e => Show (Disjunction e) Source # | |
Defined in LTK.Factors showsPrec :: Int -> Disjunction e -> ShowS # show :: Disjunction e -> String # showList :: [Disjunction e] -> ShowS # | |
Eq e => Eq (Disjunction e) Source # | |
Defined in LTK.Factors (==) :: Disjunction e -> Disjunction e -> Bool # (/=) :: Disjunction e -> Disjunction e -> Bool # | |
Ord e => Ord (Disjunction e) Source # | |
Defined in LTK.Factors compare :: Disjunction e -> Disjunction e -> Ordering # (<) :: Disjunction e -> Disjunction e -> Bool # (<=) :: Disjunction e -> Disjunction e -> Bool # (>) :: Disjunction e -> Disjunction e -> Bool # (>=) :: Disjunction e -> Disjunction e -> Bool # max :: Disjunction e -> Disjunction e -> Disjunction e # min :: Disjunction e -> Disjunction e -> Disjunction e # |
newtype Conjunction e Source #
Multiple disjunctions, joined by AND
.
Conjunction (Set (Disjunction e)) |
Instances
(Read e, Ord e) => Read (Conjunction e) Source # | |
Defined in LTK.Factors readsPrec :: Int -> ReadS (Conjunction e) # readList :: ReadS [Conjunction e] # readPrec :: ReadPrec (Conjunction e) # readListPrec :: ReadPrec [Conjunction e] # | |
Show e => Show (Conjunction e) Source # | |
Defined in LTK.Factors showsPrec :: Int -> Conjunction e -> ShowS # show :: Conjunction e -> String # showList :: [Conjunction e] -> ShowS # | |
Eq e => Eq (Conjunction e) Source # | |
Defined in LTK.Factors (==) :: Conjunction e -> Conjunction e -> Bool # (/=) :: Conjunction e -> Conjunction e -> Bool # | |
Ord e => Ord (Conjunction e) Source # | |
Defined in LTK.Factors compare :: Conjunction e -> Conjunction e -> Ordering # (<) :: Conjunction e -> Conjunction e -> Bool # (<=) :: Conjunction e -> Conjunction e -> Bool # (>) :: Conjunction e -> Conjunction e -> Bool # (>=) :: Conjunction e -> Conjunction e -> Bool # max :: Conjunction e -> Conjunction e -> Conjunction e # min :: Conjunction e -> Conjunction e -> Conjunction e # |