module NLP.Stemmer (
Algorithm(..)
, stem
, stemWords
) where
import NLP.Stemmer.C (Algorithm)
import qualified NLP.Stemmer.C as C
import Foreign (unsafePerformIO)
stem :: Algorithm -> String -> String
stem algorithm input = withStemmer algorithm (\stemmer -> C.stem stemmer input)
stemWords :: Algorithm -> [String] -> [String]
stemWords algorithm input = withStemmer algorithm (\stemmer -> mapM (C.stem stemmer) input)
withStemmer :: Algorithm -> (C.Stemmer -> IO a) -> a
withStemmer algorithm action = unsafePerformIO $ C.withStemmer algorithm action