module Main where import NLP.Hext.NaiveBayes import Data.Char import qualified Data.Text.Lazy as T ---- TEST DATA ---- data Class = Positive | Negative deriving (Eq, Ord, Show) doc1 = "I loved the movie" doc2 = "I hated the movie" doc3 = "a great movie. good movie" doc4 = "poor acting" doc5 = "great acting. a good movie" docs = [doc1, doc2, doc3, doc4, doc5] correspondingClasses = [Positive, Negative, Positive, Negative, Positive] classifiedDocs = zip docs correspondingClasses ------------------- main :: IO () main = do let teachModel = foldl (\md (sample, cl) -> teach (T.pack sample) cl md) emptyModel let review = "I hated the poor acting" let result = runBayes (teachModel classifiedDocs) review putStrLn "To run the naive bayes algorithm on\ \ the test data found in the main file, enter '1'" n <- getChar if (digitToInt n :: Int) == 1 then putStrLn $ "The review '" ++ review ++ "' is " ++ show result else return ()