Fix generating configs
This commit is contained in:
parent
5553fbc4ca
commit
5fc5f6ac64
@ -13,6 +13,7 @@ import GEval.Submit (tokenFileName)
|
|||||||
import GEval.MatchingSpecification (MatchingSpecification(ExactMatch))
|
import GEval.MatchingSpecification (MatchingSpecification(ExactMatch))
|
||||||
import qualified System.Directory as D
|
import qualified System.Directory as D
|
||||||
import Control.Conditional (whenM)
|
import Control.Conditional (whenM)
|
||||||
|
import Data.Maybe (catMaybes)
|
||||||
|
|
||||||
import System.IO
|
import System.IO
|
||||||
import System.FilePath
|
import System.FilePath
|
||||||
@ -427,22 +428,25 @@ Directory structure
|
|||||||
|
|
||||||
|
|
||||||
configContents :: [EvaluationScheme] -> FormattingOptions -> String -> String
|
configContents :: [EvaluationScheme] -> FormattingOptions -> String -> String
|
||||||
configContents schemes format testName = unwords (Prelude.map (\scheme -> ("--metric " ++ (show scheme))) schemes) ++
|
configContents schemes format testName =
|
||||||
(if testName /= defaultTestName
|
unwords $ catMaybes ((Prelude.map (\scheme -> (Just $ "--metric " ++ (show scheme))) schemes)
|
||||||
then
|
++ [testNameOpt]
|
||||||
" --test-name " ++ testName
|
++ (precisionOpt format)
|
||||||
else
|
++ [inHeaderOpts, outHeaderOpts])
|
||||||
"") ++
|
where precisionOpt (FormattingOptions m b) = [
|
||||||
(precisionOpt format) ++
|
maybe Nothing (Just . printf "--precision %d") m,
|
||||||
inHeaderOpts ++
|
bool Nothing (Just "--show-as-percentage") b ]
|
||||||
outHeaderOpts
|
|
||||||
where precisionOpt (FormattingOptions m b) = maybe "" (printf "--precision %d ") m ++ bool "" "--show-as-percentage" b
|
|
||||||
((EvaluationScheme mainMetric _):_) = schemes
|
((EvaluationScheme mainMetric _):_) = schemes
|
||||||
|
testNameOpt = if testName /= defaultTestName
|
||||||
|
then
|
||||||
|
(Just (" --test-name " ++ testName))
|
||||||
|
else
|
||||||
|
Nothing
|
||||||
inHeaderOpts = getHeaderOpts "in-header" inHeaderContents
|
inHeaderOpts = getHeaderOpts "in-header" inHeaderContents
|
||||||
outHeaderOpts = getHeaderOpts "out-header" outHeaderContents
|
outHeaderOpts = getHeaderOpts "out-header" outHeaderContents
|
||||||
getHeaderOpts opt selector = case selector mainMetric of
|
getHeaderOpts opt selector = case selector mainMetric of
|
||||||
Just _ -> " --" ++ opt ++ " " ++ (opt <.> "tsv")
|
Just _ -> Just (" --" ++ opt ++ " " ++ (opt <.> "tsv"))
|
||||||
Nothing -> ""
|
Nothing -> Nothing
|
||||||
|
|
||||||
-- Originally train content was in one file, to avoid large changes
|
-- Originally train content was in one file, to avoid large changes
|
||||||
-- for the time being we are using the original function.
|
-- for the time being we are using the original function.
|
||||||
|
Loading…
Reference in New Issue
Block a user