use a type MetricValue instead of just Doubles

This commit is contained in:
Filip Gralinski 2015-08-22 20:29:56 +02:00 committed by Filip Gralinski
parent 4efd99bef9
commit 1ca75163b0
2 changed files with 6 additions and 3 deletions

View File

@ -2,6 +2,7 @@ module GEval
( geval,
gevalCore,
Metric(..),
MetricValue,
GEvalSpecification(..),
GEvalOptions(..),
defaultGEvalSpecification,
@ -28,6 +29,8 @@ import qualified System.Directory as D
import System.FilePath
import Data.Maybe
type MetricValue = Double
data Metric = RMSE | MSE | BLEU
deriving (Show, Read)
@ -84,7 +87,7 @@ defaultGEvalSpecification = GEvalSpecification {
gesMetric = defaultMetric }
geval :: GEvalSpecification -> IO (Double)
geval :: GEvalSpecification -> IO (MetricValue)
geval gevalSpec = do
unlessM (D.doesDirectoryExist outDirectory) $ throwM $ NoOutDirectory outDirectory
unlessM (D.doesDirectoryExist expectedDirectory) $ throwM $ NoExpectedDirectory expectedDirectory
@ -100,7 +103,7 @@ geval gevalSpec = do
testName = gesTestName gevalSpec
metric = gesMetric gevalSpec
gevalCore :: Metric -> String -> String -> IO (Double)
gevalCore :: Metric -> String -> String -> IO (MetricValue)
gevalCore MSE expectedFilePath outFilePath = do
unlessM (D.doesFileExist expectedFilePath) $ throwM $ NoExpectedFile expectedFilePath
unlessM (D.doesFileExist outFilePath) $ throwM $ NoOutFile outFilePath

View File

@ -57,7 +57,7 @@ metricReader = option auto
<> metavar "METRIC"
<> help "Metric to be used" )
runGEval :: [String] -> IO (Either (ParserResult GEvalOptions) (Maybe Double))
runGEval :: [String] -> IO (Either (ParserResult GEvalOptions) (Maybe MetricValue))
runGEval args =
case parserResult of
Success opts -> do