-- analyze :: Database -> [String] -> [String] -> IO Results
-- analyze db langs cands = 
--   do cs <- manyData db fetchBData cands
--      ts <- manyData db fetchAData langs
-- 
--      return (foldr (compAll ts) M.empty cs)
-- 
-- compAll :: [Lang] -> Lang -> Results -> Results
-- compAll ts (cn,cd) r = 
--   foldr (\(tn,td) -> mupd tn cn (cosine td cd)) r ts
--   
-- mupd :: String -> String -> Double -> Results -> Results
-- mupd tn cn v r = case M.lookup tn r of
--                    Just vs -> M.insert tn ((v,cn) : vs) r
--                    Nothing -> M.insert tn ((v,cn) : []) r
-- 
-- manyData db f ns = sequence (fmap (f db) ns)
-- 
stats :: [(String,String)] -> String
stats ss = let total = length ss
               correct = length (filter (\(a,b) -> a == b) ss)
               percent = correct * 100 `div` total
           in "Accuracy: "
              ++ (show correct) 
              ++ " / " 
              ++ (show total)
              ++ " ("
              ++ (show percent)
              ++ ("%)")
stats :: [(String,String)] -> String
stats ss = let total = length ss
               correct = length (filter (\(a,b) -> a == b) ss)
               percent = correct * 100 `div` total
           in "Accuracy: "
              ++ (show correct) 
              ++ " / " 
              ++ (show total)
              ++ " ("
              ++ (show percent)
              ++ ("%)")
stats ss = let total = length ss
               correct = length (filter (\(a,b) -> a == b) ss)
               percent = correct * 100 `div` total
           in "Accuracy: "
              ++ (show correct) 
              ++ " / " 
              ++ (show total)
              ++ " ("
              ++ (show percent)
              ++ ("%)")