Safe Haskell | None |
---|
The module implements directed acyclic word graphs (DAWGs) internaly represented as minimal acyclic deterministic finite-state automata. The implementation provides fast insert and delete operations which can be used to build the DAWG structure incrementaly.
- data DAWG a b = DAWG {}
- numStates :: DAWG a b -> Int
- lookup :: Enum a => [a] -> DAWG a b -> Maybe b
- empty :: Ord b => DAWG a b
- fromList :: (Enum a, Ord b) => [([a], b)] -> DAWG a b
- fromListWith :: (Enum a, Ord b) => (b -> b -> b) -> [([a], b)] -> DAWG a b
- fromLang :: Enum a => [[a]] -> DAWG a ()
- insert :: (Enum a, Ord b) => [a] -> b -> DAWG a b -> DAWG a b
- insertWith :: (Enum a, Ord b) => (b -> b -> b) -> [a] -> b -> DAWG a b -> DAWG a b
- delete :: (Enum a, Ord b) => [a] -> DAWG a b -> DAWG a b
- assocs :: Enum a => DAWG a b -> [([a], b)]
- keys :: Enum a => DAWG a b -> [[a]]
- elems :: DAWG a b -> [b]
DAWG type
A Graph
with one root from which all other graph nodes should
be accesible. Parameter a
is a phantom parameter which represents
symbol type.
Query
Construction
fromList :: (Enum a, Ord b) => [([a], b)] -> DAWG a bSource
Construct DAWG from the list of (word, value) pairs.
fromListWith :: (Enum a, Ord b) => (b -> b -> b) -> [([a], b)] -> DAWG a bSource
Construct DAWG from the list of (word, value) pairs with a combining function. The combining function is applied strictly.
fromLang :: Enum a => [[a]] -> DAWG a ()Source
Make DAWG from the list of words. Annotate each word with
the ()
value.
Insertion
insert :: (Enum a, Ord b) => [a] -> b -> DAWG a b -> DAWG a bSource
Insert the (key, value) pair into the DAWG.
insertWith :: (Enum a, Ord b) => (b -> b -> b) -> [a] -> b -> DAWG a b -> DAWG a bSource
Insert with a function, combining new value and old value.
insertWith
f key value d will insert the pair (key, value) into d if
key does not exist in the DAWG. If the key does exist, the function
will insert the pair (key, f new_value old_value).