polh-lexicon-0.2: src/NLP/Polh/Util.hs
-- | Some utility functions for working with the dictionary.
module NLP.Polh.Util
( allForms
, hasForm
, addForm
) where
import qualified Data.Text as T
import NLP.Polh.Types
-- | All format (base form + other forms) of the lexeme.
allForms :: LexEntry -> [T.Text]
allForms lx
= text (lemma lx)
++ concatMap text (forms lx)
-- | Does lexeme take the given form?
hasForm :: LexEntry -> T.Text -> Bool
hasForm lx x = x `elem` allForms lx
-- | Add new word form to the lexeme description.
addForm :: WordForm -> LexEntry -> LexEntry
addForm x lx = lx { forms = (x : forms lx) }