use a type MetricValue instead of just Doubles
This commit is contained in:
parent
4efd99bef9
commit
1ca75163b0
@ -2,6 +2,7 @@ module GEval
|
|||||||
( geval,
|
( geval,
|
||||||
gevalCore,
|
gevalCore,
|
||||||
Metric(..),
|
Metric(..),
|
||||||
|
MetricValue,
|
||||||
GEvalSpecification(..),
|
GEvalSpecification(..),
|
||||||
GEvalOptions(..),
|
GEvalOptions(..),
|
||||||
defaultGEvalSpecification,
|
defaultGEvalSpecification,
|
||||||
@ -28,6 +29,8 @@ import qualified System.Directory as D
|
|||||||
import System.FilePath
|
import System.FilePath
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
|
|
||||||
|
type MetricValue = Double
|
||||||
|
|
||||||
data Metric = RMSE | MSE | BLEU
|
data Metric = RMSE | MSE | BLEU
|
||||||
deriving (Show, Read)
|
deriving (Show, Read)
|
||||||
|
|
||||||
@ -84,7 +87,7 @@ defaultGEvalSpecification = GEvalSpecification {
|
|||||||
gesMetric = defaultMetric }
|
gesMetric = defaultMetric }
|
||||||
|
|
||||||
|
|
||||||
geval :: GEvalSpecification -> IO (Double)
|
geval :: GEvalSpecification -> IO (MetricValue)
|
||||||
geval gevalSpec = do
|
geval gevalSpec = do
|
||||||
unlessM (D.doesDirectoryExist outDirectory) $ throwM $ NoOutDirectory outDirectory
|
unlessM (D.doesDirectoryExist outDirectory) $ throwM $ NoOutDirectory outDirectory
|
||||||
unlessM (D.doesDirectoryExist expectedDirectory) $ throwM $ NoExpectedDirectory expectedDirectory
|
unlessM (D.doesDirectoryExist expectedDirectory) $ throwM $ NoExpectedDirectory expectedDirectory
|
||||||
@ -100,7 +103,7 @@ geval gevalSpec = do
|
|||||||
testName = gesTestName gevalSpec
|
testName = gesTestName gevalSpec
|
||||||
metric = gesMetric gevalSpec
|
metric = gesMetric gevalSpec
|
||||||
|
|
||||||
gevalCore :: Metric -> String -> String -> IO (Double)
|
gevalCore :: Metric -> String -> String -> IO (MetricValue)
|
||||||
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
|
||||||
|
@ -57,7 +57,7 @@ metricReader = option auto
|
|||||||
<> metavar "METRIC"
|
<> metavar "METRIC"
|
||||||
<> help "Metric to be used" )
|
<> help "Metric to be used" )
|
||||||
|
|
||||||
runGEval :: [String] -> IO (Either (ParserResult GEvalOptions) (Maybe Double))
|
runGEval :: [String] -> IO (Either (ParserResult GEvalOptions) (Maybe MetricValue))
|
||||||
runGEval args =
|
runGEval args =
|
||||||
case parserResult of
|
case parserResult of
|
||||||
Success opts -> do
|
Success opts -> do
|
||||||
|
Loading…
Reference in New Issue
Block a user