import DictSearchParallel(dict_search)
import InputReader(formMatrixFromInput)
import System.Exit(die)
import System.Environment(getArgs)

main :: IO ()
main = do args <- getArgs
          case args of
            [fileName, dictFile, rows, columns] -> do
                contents <- readFile fileName
                query_content <- readFile dictFile
                let query_words = words query_content
                let res = dict_search (formMatrixFromInput contents m n) m n query_words
                let present_words = (filter is_present (zip query_words res))
                putStrLn ("#present_words: " ++ (show $ length present_words))
                where
                    m = (read rows) :: Int
                    n = (read columns) :: Int
                    is_present (_,y) = y
            _ -> do
                die $ "Usage: word_exist <sample_input.txt> <rows> <columns> <word>"
