precision is part of specification now

This commit is contained in:
Filip Gralinski 2018-01-25 09:11:04 +01:00 committed by Filip Gralinski
parent e7518a1141
commit 6cfefed0c1
3 changed files with 6 additions and 5 deletions

View File

@ -18,7 +18,7 @@ main = do
Right (_, Nothing) -> return () Right (_, Nothing) -> return ()
showTheResult :: GEvalOptions -> MetricValue -> IO () showTheResult :: GEvalOptions -> MetricValue -> IO ()
showTheResult opts val = putStrLn $ formatTheResult (geoPrecision opts) val showTheResult opts val = putStrLn $ formatTheResult (gesPrecision $ geoSpec opts) val
formatTheResult :: Maybe Int -> MetricValue -> String formatTheResult :: Maybe Int -> MetricValue -> String
formatTheResult Nothing = show formatTheResult Nothing = show

View File

@ -147,7 +147,8 @@ data GEvalSpecification = GEvalSpecification
gesOutFile :: String, gesOutFile :: String,
gesExpectedFile :: String, gesExpectedFile :: String,
gesInputFile :: String, gesInputFile :: String,
gesMetric :: Metric } gesMetric :: Metric,
gesPrecision :: Maybe Int}
getExpectedDirectory :: GEvalSpecification -> FilePath getExpectedDirectory :: GEvalSpecification -> FilePath
getExpectedDirectory spec = fromMaybe outDirectory $ gesExpectedDirectory spec getExpectedDirectory spec = fromMaybe outDirectory $ gesExpectedDirectory spec
@ -157,7 +158,6 @@ data GEvalSpecialCommand = Init | LineByLine
data GEvalOptions = GEvalOptions data GEvalOptions = GEvalOptions
{ geoSpecialCommand :: Maybe GEvalSpecialCommand, { geoSpecialCommand :: Maybe GEvalSpecialCommand,
geoPrecision :: Maybe Int,
geoSpec :: GEvalSpecification } geoSpec :: GEvalSpecification }
@ -206,7 +206,8 @@ defaultGEvalSpecification = GEvalSpecification {
gesOutFile = defaultOutFile, gesOutFile = defaultOutFile,
gesExpectedFile = defaultExpectedFile, gesExpectedFile = defaultExpectedFile,
gesInputFile = defaultInputFile, gesInputFile = defaultInputFile,
gesMetric = defaultMetric } gesMetric = defaultMetric,
gesPrecision = Nothing}
isEmptyFile :: FilePath -> IO (Bool) isEmptyFile :: FilePath -> IO (Bool)
isEmptyFile path = do isEmptyFile path = do

View File

@ -34,7 +34,6 @@ optionsParser = GEvalOptions
(flag' LineByLine (flag' LineByLine
( long "line-by-line" ( long "line-by-line"
<> help "Give scores for each line rather than the whole test set" ))) <> help "Give scores for each line rather than the whole test set" )))
<*> optional precisionArgParser
<*> specParser <*> specParser
precisionArgParser :: Parser Int precisionArgParser :: Parser Int
@ -80,6 +79,7 @@ specParser = GEvalSpecification
<> metavar "INPUT" <> metavar "INPUT"
<> help "The name of the file with the input (applicable only for some metrics)" ) <> help "The name of the file with the input (applicable only for some metrics)" )
<*> metricReader <*> metricReader
<*> optional precisionArgParser
metricReader :: Parser Metric metricReader :: Parser Metric
metricReader = option auto metricReader = option auto