This commit is contained in:
Filip Gralinski 2015-08-22 19:35:19 +02:00 committed by Filip Gralinski
parent d75c1b646b
commit 866917fc3f

View File

@ -28,7 +28,7 @@ import qualified System.Directory as D
import System.FilePath import System.FilePath
import Data.Maybe import Data.Maybe
data Metric = MSE | BLEU data Metric = RMSE | MSE | BLEU
deriving (Show, Read) deriving (Show, Read)
defaultOutDirectory = "." defaultOutDirectory = "."
@ -37,7 +37,7 @@ defaultOutFile = "out.tsv"
defaultExpectedFile = "expected.tsv" defaultExpectedFile = "expected.tsv"
defaultMetric :: Metric defaultMetric :: Metric
defaultMetric = MSE defaultMetric = RMSE
data GEvalSpecification = GEvalSpecification data GEvalSpecification = GEvalSpecification
@ -104,12 +104,15 @@ gevalCore :: Metric -> String -> String -> IO (Double)
gevalCore MSE expectedFilePath outFilePath = do gevalCore MSE expectedFilePath outFilePath = do
unlessM (D.doesFileExist expectedFilePath) $ throwM $ NoExpectedFile expectedFilePath unlessM (D.doesFileExist expectedFilePath) $ throwM $ NoExpectedFile expectedFilePath
unlessM (D.doesFileExist outFilePath) $ throwM $ NoOutFile outFilePath unlessM (D.doesFileExist outFilePath) $ throwM $ NoOutFile outFilePath
mse <- runResourceT $ runResourceT $
(getZipSource $ (,) (getZipSource $ (,)
<$> ZipSource (items expectedFilePath) <$> ZipSource (items expectedFilePath)
<*> ZipSource (items outFilePath)) <*> ZipSource (items outFilePath))
$$ (CL.map itemError $$ (CL.map itemError
=$ averageC) =$ averageC)
gevalCore RMSE expectedFilePath outFilePath = do
mse <- gevalCore MSE expectedFilePath outFilePath
return $ mse ** 0.5 return $ mse ** 0.5
averageC :: MonadResource m => Sink Double m Double averageC :: MonadResource m => Sink Double m Double