fromDB :: Opts -> IO ()
fromDB os = 
  do db <- connectDB (opDB os)
     langs <- (fmap fst . M.toList) 
              <$> fetchAllLengths db "dataAll"
     let sets = divie' "   " (opNum os) langs
     st <- fetchSt db (opNum os)
     let crawl1' = crawl1 st os sets
     results <- foldM crawl1' M.empty sets
     
     let winners = fmap (snd . maximum) results
         mistakes = filter (\(a,b) -> a /= b) . M.toList $ winners
         ml = maxlen mistakes

     putStrLn (":: Database analysis on \"" ++ opDB os ++ "\" ::")
     putStrLn ""
     putStrLn ("(Using the " ++ show (opNumTrigrams os) 
               ++ " most frequent TriGrams from each list)")
     putStrLn ""
     (putStrLn . stats . M.toList) winners
     putStrLn ""

     putStrLn "The following mistakes occured:"
     putStrLn ""
     (sequence_ . fmap (putStrLn . idAs ml)) mistakes
     putStrLn ""
     putStrLn ""
     putStrLn "Mistake Details:"
     putStrLn ""
     (sequence_ . fmap (Main.prettyprint ml results)) mistakes
fromDB :: Opts -> IO ()
fromDB os = 
  do db <- connectDB (opDB os)
     langs <- (fmap fst . M.toList) 
              <$> fetchAllLengths db "dataAll"
     let sets = divie' "   " (opNum os) langs
     st <- fetchSt db (opNum os)
     let crawl1' = crawl1 st os sets
     results <- foldM crawl1' M.empty sets
     
     let winners = fmap (snd . maximum) results
         mistakes = filter (\(a,b) -> a /= b) . M.toList $ winners
         ml = maxlen mistakes

     putStrLn (":: Database analysis on \"" ++ opDB os ++ "\" ::")
     putStrLn ""
     putStrLn ("(Using the " ++ show (opNumTrigrams os) 
               ++ " most frequent TriGrams from each list)")
     putStrLn ""
     (putStrLn . stats . M.toList) winners
     putStrLn ""

     putStrLn "The following mistakes occured:"
     putStrLn ""
     (sequence_ . fmap (putStrLn . idAs ml)) mistakes
     putStrLn ""
     putStrLn ""
     putStrLn "Mistake Details:"
     putStrLn ""
     (sequence_ . fmap (Main.prettyprint ml results)) mistakes
fromDB os = 
  do db <- connectDB (opDB os)
     langs <- (fmap fst . M.toList) 
              <$> fetchAllLengths db "dataAll"
     let sets = divie' "   " (opNum os) langs
     st <- fetchSt db (opNum os)
     let crawl1' = crawl1 st os sets
     results <- foldM crawl1' M.empty sets
     
     let winners = fmap (snd . maximum) results
         mistakes = filter (\(a,b) -> a /= b) . M.toList $ winners
         ml = maxlen mistakes

     putStrLn (":: Database analysis on \"" ++ opDB os ++ "\" ::")
     putStrLn ""
     putStrLn ("(Using the " ++ show (opNumTrigrams os) 
               ++ " most frequent TriGrams from each list)")
     putStrLn ""
     (putStrLn . stats . M.toList) winners
     putStrLn ""

     putStrLn "The following mistakes occured:"
     putStrLn ""
     (sequence_ . fmap (putStrLn . idAs ml)) mistakes
     putStrLn ""
     putStrLn ""
     putStrLn "Mistake Details:"
     putStrLn ""
     (sequence_ . fmap (Main.prettyprint ml results)) mistakes