Better diagnostics for unknown metrics
This commit is contained in:
parent
36a930d159
commit
8c2fa3d8ed
@ -135,6 +135,7 @@ data GEvalException = NoExpectedFile FilePath
|
||||
| UnexpectedMultipleOutputs
|
||||
| OtherException String
|
||||
| NoHeaderFile FilePath
|
||||
| UnknownMetric String
|
||||
deriving (Eq)
|
||||
|
||||
instance Exception GEvalException
|
||||
@ -157,6 +158,7 @@ instance Show GEvalException where
|
||||
show UnexpectedMultipleOutputs = "Multiple outputs are not possible in this mode, use -o option to select an output file"
|
||||
show (OtherException message) = message
|
||||
show (NoHeaderFile filePath) = somethingWrongWithFilesMessage "No file with header specification" filePath
|
||||
show (UnknownMetric t) = "Unknown or broken metric definition: " ++ t
|
||||
|
||||
somethingWrongWithFilesMessage :: String -> FilePath -> String
|
||||
somethingWrongWithFilesMessage msg filePath = Prelude.concat
|
||||
|
@ -15,6 +15,7 @@ module GEval.Metric
|
||||
import Data.Word
|
||||
import Data.Text hiding (map)
|
||||
import Data.Monoid ((<>))
|
||||
import Control.Exception
|
||||
|
||||
import GEval.Common
|
||||
import GEval.Clippings
|
||||
@ -192,7 +193,7 @@ instance Read Metric where
|
||||
readsPrec _ ('M':'u':'l':'t':'i':'L':'a':'b':'e':'l':'-':'L':'o':'g':'L':'o':'s':'s':theRest) = [(MultiLabelLogLoss, theRest)]
|
||||
readsPrec _ ('M':'u':'l':'t':'i':'L':'a':'b':'e':'l':'-':'L':'i':'k':'e':'l':'i':'h':'o':'o':'d':theRest) = [(MultiLabelLikelihood, theRest)]
|
||||
readsPrec _ ('H':'a':'v':'e':'r':'s':'i':'n':'e':theRest) = [(Haversine, theRest)]
|
||||
|
||||
readsPrec _ t = throw $ UnknownMetric t
|
||||
|
||||
|
||||
data MetricOrdering = TheLowerTheBetter | TheHigherTheBetter
|
||||
|
Loading…
Reference in New Issue
Block a user