handle numbers combined with text
This commit is contained in:
parent
b52819f67e
commit
e66a8d8341
@ -201,5 +201,8 @@ itemError :: (Double, Double) -> Double
|
||||
itemError (exp, out) = (exp-out)**2
|
||||
|
||||
getValue :: Either String (Double, Text) -> Double
|
||||
getValue (Right (x, _)) = x
|
||||
getValue (Right (x, reminder)) =
|
||||
if Data.Text.null reminder || Data.Text.head reminder == '\t'
|
||||
then x
|
||||
else throw $ UnexpectedData "number expected"
|
||||
getValue (Left s) = throw $ UnexpectedData s
|
||||
|
@ -42,6 +42,9 @@ main = hspec $ do
|
||||
runGEvalTest "empty-output" `shouldThrow` (== EmptyOutput)
|
||||
it "unexpected data is handled" $
|
||||
runGEvalTest "unexpected-data" `shouldThrow` (== UnexpectedData "input does not start with a digit")
|
||||
it "unwanted data is handled" $
|
||||
runGEvalTest "unwanted-data" `shouldThrow` (== UnexpectedData "number expected")
|
||||
|
||||
|
||||
extractVal :: (Either (ParserResult GEvalOptions) (Maybe MetricValue)) -> IO MetricValue
|
||||
extractVal (Right (Just val)) = return val
|
||||
|
4
test/unwanted-data/unwanted-data-solution/test-A/out.tsv
Normal file
4
test/unwanted-data/unwanted-data-solution/test-A/out.tsv
Normal file
@ -0,0 +1,4 @@
|
||||
1 X
|
||||
2xyz Y
|
||||
3.3 Z
|
||||
4.0 Z
|
|
1
test/unwanted-data/unwanted-data/config.txt
Normal file
1
test/unwanted-data/unwanted-data/config.txt
Normal file
@ -0,0 +1 @@
|
||||
--metric RMSE
|
4
test/unwanted-data/unwanted-data/test-A/expected.tsv
Normal file
4
test/unwanted-data/unwanted-data/test-A/expected.tsv
Normal file
@ -0,0 +1,4 @@
|
||||
1.2
|
||||
2.3
|
||||
1.0
|
||||
5.0
|
|
4
test/unwanted-data/unwanted-data/test-A/in.tsv
Normal file
4
test/unwanted-data/unwanted-data/test-A/in.tsv
Normal file
@ -0,0 +1,4 @@
|
||||
1 a
|
||||
2 b
|
||||
1 a
|
||||
2 a
|
|
Loading…
Reference in New Issue
Block a user