Metrics can be selected by name
This commit is contained in:
parent
d21cfe64fb
commit
425c1b5102
@ -38,7 +38,7 @@ import GEval.Validation
|
|||||||
import GEval.Model
|
import GEval.Model
|
||||||
import GEval.ModelTraining
|
import GEval.ModelTraining
|
||||||
|
|
||||||
import Data.List (intercalate)
|
import Data.List (find, intercalate)
|
||||||
|
|
||||||
import Data.Conduit.SmartSource
|
import Data.Conduit.SmartSource
|
||||||
import Data.CartesianStrings
|
import Data.CartesianStrings
|
||||||
@ -193,7 +193,8 @@ specParser = GEvalSpecification
|
|||||||
<> showDefault
|
<> showDefault
|
||||||
<> 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)" )
|
||||||
<*> ((flip fromMaybe) <$> (singletonMaybe <$> altMetricReader) <*> metricReader)
|
<*> (selectMetricsByName <$> selectMetricReader
|
||||||
|
<*> ((flip fromMaybe) <$> (singletonMaybe <$> altMetricReader) <*> metricReader))
|
||||||
<*> formatParser
|
<*> formatParser
|
||||||
<*> (optional $ option auto
|
<*> (optional $ option auto
|
||||||
( long "tokenizer"
|
( long "tokenizer"
|
||||||
@ -238,6 +239,13 @@ specParser = GEvalSpecification
|
|||||||
<> metavar "FILE"
|
<> metavar "FILE"
|
||||||
<> help "One-line TSV file specifying a list of field names for output and expected files"))
|
<> help "One-line TSV file specifying a list of field names for output and expected files"))
|
||||||
|
|
||||||
|
selectMetricsByName :: [String] -> [EvaluationScheme] -> [EvaluationScheme]
|
||||||
|
selectMetricsByName [] schemes = schemes
|
||||||
|
selectMetricsByName metricNames schemes = map (selectMetric schemes) metricNames
|
||||||
|
where selectMetric schemes metricName = case find (\s -> evaluationSchemeName s == metricName) schemes of
|
||||||
|
Just scheme -> scheme
|
||||||
|
Nothing -> error $ "Cannot find metric named '" ++ metricName ++ "'"
|
||||||
|
|
||||||
defaultMinFrequency :: Integer
|
defaultMinFrequency :: Integer
|
||||||
defaultMinFrequency = 1
|
defaultMinFrequency = 1
|
||||||
|
|
||||||
@ -298,6 +306,13 @@ altMetricReader = optional $ option auto
|
|||||||
<> metavar "METRIC"
|
<> metavar "METRIC"
|
||||||
<> help "Alternative metric (overrides --metric option)" )
|
<> help "Alternative metric (overrides --metric option)" )
|
||||||
|
|
||||||
|
selectMetricReader :: Parser [String]
|
||||||
|
selectMetricReader = many $ strOption
|
||||||
|
( long "select-metric"
|
||||||
|
<> metavar "METRIC-NAME"
|
||||||
|
<> help "Select metric(s) by name" )
|
||||||
|
|
||||||
|
|
||||||
runGEval :: [String] -> IO (Either (ParserResult GEvalOptions) (Maybe [(SourceSpec, [MetricResult])]))
|
runGEval :: [String] -> IO (Either (ParserResult GEvalOptions) (Maybe [(SourceSpec, [MetricResult])]))
|
||||||
runGEval args = do
|
runGEval args = do
|
||||||
ret <- runGEvalGetOptions args
|
ret <- runGEvalGetOptions args
|
||||||
|
Loading…
Reference in New Issue
Block a user