From 36a3d8c949cf7211508afecc1afaf4f4a38f740a Mon Sep 17 00:00:00 2001 From: Filip Gralinski Date: Mon, 27 Jan 2020 22:23:43 +0100 Subject: [PATCH] Gracefully degrade when bootstrap is not (yet) handled --- src/GEval/Core.hs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/GEval/Core.hs b/src/GEval/Core.hs index 0ddc736..b8a4ed3 100644 --- a/src/GEval/Core.hs +++ b/src/GEval/Core.hs @@ -407,6 +407,17 @@ singleLineAsLineSource :: LineInFile -> (Text -> ItemTarget) -> (Text -> Text) - singleLineAsLineSource (LineInFile sourceSpec lineNo line) itemDecoder preprocess = LineSource (CL.sourceList [line]) itemDecoder preprocess sourceSpec lineNo +handleBootstrap :: Metric -> Bool +handleBootstrap (Mean _) = False +handleBootstrap CharMatch = False +handleBootstrap (LogLossHashed _) = False +handleBootstrap (LikelihoodHashed _ ) = False +handleBootstrap Pearson = False +handleBootstrap Spearman = False +handleBootstrap (ProbabilisticMultiLabelFMeasure beta) = False +handleBootstrap (ProbabilisticSoftFMeasure beta) = False +handleBootstrap _ = True + -- | Runs evaluation for a given metric using the sources specified -- for input, expected output and output. Returns the metric value. -- Throws @GEvalException@ if something was wrong in the data (e.g. @@ -427,7 +438,9 @@ gevalCore metric mSelector preprocess mBootstrapResampling inputSource expectedS (fileAsLineSource outSource mSelector preprocess) where go = case mBootstrapResampling of Nothing -> gevalCoreOnSources - Just bootstrapResampling -> gevalBootstrapOnSources bootstrapResampling + Just bootstrapResampling -> if handleBootstrap metric + then gevalBootstrapOnSources bootstrapResampling + else gevalCoreOnSources isEmptyFileSource :: SourceSpec -> IO Bool isEmptyFileSource (FilePathSpec filePath) = isEmptyFile filePath