module NLP.Nerf.Dict.NELexicon
( parseNELexicon
, readNELexicon
) where
import qualified Data.Text.Lazy as L
import qualified Data.Text.Lazy.IO as L
import NLP.Nerf.Dict.Base
parseNELexicon :: L.Text -> [Entry]
parseNELexicon = map parseLine . L.lines
parseLine :: L.Text -> Entry
parseLine line = case L.break (==';') line of
(_type, _form) -> Entry (L.toStrict $ L.drop 2 _form) (L.toStrict _type)
_ -> error $ "parseLine: invalid line \"" ++ L.unpack line ++ "\""
readNELexicon :: FilePath -> IO [Entry]
readNELexicon = fmap parseNELexicon . L.readFile