Handle DOS/Windows end-of-lines
This commit is contained in:
parent
ed1bb47a81
commit
0f9ab275ef
@ -5,7 +5,7 @@
|
|||||||
{-# LANGUAGE FlexibleInstances #-}
|
{-# LANGUAGE FlexibleInstances #-}
|
||||||
{-# LANGUAGE ScopedTypeVariables #-}
|
{-# LANGUAGE ScopedTypeVariables #-}
|
||||||
{-# LANGUAGE PackageImports #-}
|
{-# LANGUAGE PackageImports #-}
|
||||||
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
|
|
||||||
module GEval.Core
|
module GEval.Core
|
||||||
( geval,
|
( geval,
|
||||||
@ -509,10 +509,12 @@ data FileProcessingOptions = FileProcessingOptions {
|
|||||||
fileProcessingOptionsPreprocess :: (Text -> Text),
|
fileProcessingOptionsPreprocess :: (Text -> Text),
|
||||||
fileProcessingOptionsHeader :: Maybe TabularHeader }
|
fileProcessingOptionsHeader :: Maybe TabularHeader }
|
||||||
|
|
||||||
|
cleanLine :: Text -> Text
|
||||||
|
cleanLine = replace "\r" ""
|
||||||
|
|
||||||
fileAsLineSource :: SourceSpec -> FileProcessingOptions -> LineSource (ResourceT IO)
|
fileAsLineSource :: SourceSpec -> FileProcessingOptions -> LineSource (ResourceT IO)
|
||||||
fileAsLineSource spec options =
|
fileAsLineSource spec options =
|
||||||
LineSource ((smartSource spec) .| autoDecompress .| CT.decodeUtf8Lenient .| CT.lines .| processHeader mHeader) (select (getDataFormat spec) mSelector) preprocess spec 1
|
LineSource ((smartSource spec) .| autoDecompress .| CT.decodeUtf8Lenient .| CT.lines .| CL.map cleanLine .| processHeader mHeader) (select (getDataFormat spec) mSelector) preprocess spec 1
|
||||||
where mSelector = fileProcessingOptionsSelector options
|
where mSelector = fileProcessingOptionsSelector options
|
||||||
preprocess = fileProcessingOptionsPreprocess options
|
preprocess = fileProcessingOptionsPreprocess options
|
||||||
mHeader = fileProcessingOptionsHeader options
|
mHeader = fileProcessingOptionsHeader options
|
||||||
|
@ -336,6 +336,8 @@ main = hspec $ do
|
|||||||
["one", "one"]) `shouldBeAlmost` 0.5
|
["one", "one"]) `shouldBeAlmost` 0.5
|
||||||
it "simple test" $ do
|
it "simple test" $ do
|
||||||
runGEvalTest "map-simple" `shouldReturnAlmost` 0.444444444
|
runGEvalTest "map-simple" `shouldReturnAlmost` 0.444444444
|
||||||
|
it "dos-end-of-lines" $
|
||||||
|
runGEvalTest "dos-end-of-line" `shouldReturnAlmost` 0.75
|
||||||
describe "LogLoss" $ do
|
describe "LogLoss" $ do
|
||||||
it "simple" $ do
|
it "simple" $ do
|
||||||
runGEvalTest "logloss-simple" `shouldReturnAlmost` 0.31824
|
runGEvalTest "logloss-simple" `shouldReturnAlmost` 0.31824
|
||||||
|
BIN
test/dos-end-of-line/dos-end-of-line-solution/test-A/out.tsv.gz
Normal file
BIN
test/dos-end-of-line/dos-end-of-line-solution/test-A/out.tsv.gz
Normal file
Binary file not shown.
1
test/dos-end-of-line/dos-end-of-line/config.txt
Normal file
1
test/dos-end-of-line/dos-end-of-line/config.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
--metric MAP
|
4
test/dos-end-of-line/dos-end-of-line/test-A/expected.tsv
Normal file
4
test/dos-end-of-line/dos-end-of-line/test-A/expected.tsv
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
foo
|
||||||
|
bar
|
||||||
|
baz
|
||||||
|
baz
|
|
Loading…
Reference in New Issue
Block a user