Introduce Filter type

This commit is contained in:
Filip Gralinski 2020-05-13 08:13:31 +02:00
parent c1b65531b9
commit 6f6c96969d
2 changed files with 8 additions and 5 deletions

View File

@ -266,7 +266,7 @@ extensionsHandled = ["tsv", "jsonl"]
data LineSource m = LineSource (ConduitT () Text m ()) (Text -> ItemTarget) (Text -> Text) SourceSpec Word32 data LineSource m = LineSource (ConduitT () Text m ()) (Text -> ItemTarget) (Text -> Text) SourceSpec Word32
data LineSourcesSpecification m = LineSourcesSpecification { data LineSourcesSpecification m = LineSourcesSpecification {
lineSourcesFilter :: Maybe (Text -> Bool), lineSourcesFilter :: Filter,
lineSourcesInputSource :: LineSource m, lineSourcesInputSource :: LineSource m,
lineSourcesExpectedSource :: LineSource m, lineSourcesExpectedSource :: LineSource m,
lineSourcesOutputSource :: LineSource m } lineSourcesOutputSource :: LineSource m }
@ -377,7 +377,7 @@ checkAndGetDataSources forceInput gevalSpec = do
challengeDataSourceExpected = expectedSource, challengeDataSourceExpected = expectedSource,
challengeDataSourceSelector = mSelector, challengeDataSourceSelector = mSelector,
challengeDataSourcePreprocess = preprocess, challengeDataSourcePreprocess = preprocess,
challengeDataSourceFilter = Nothing, challengeDataSourceFilter = Filter Nothing,
challengeDataSourceInHeader = mInHeader, challengeDataSourceInHeader = mInHeader,
challengeDataSourceOutHeader = mOutHeader } challengeDataSourceOutHeader = mOutHeader }
@ -502,7 +502,7 @@ gevalCoreOnSingleLines metric preprocess inpDecoder inpLine expDecoder expLine o
then preprocess then preprocess
else id else id
lsSpec = LineSourcesSpecification { lsSpec = LineSourcesSpecification {
lineSourcesFilter = Nothing, lineSourcesFilter = Filter Nothing,
lineSourcesInputSource = singleLineAsLineSource inpLine inpDecoder preprocess, lineSourcesInputSource = singleLineAsLineSource inpLine inpDecoder preprocess,
lineSourcesExpectedSource = singleLineAsLineSource expLine expDecoder outputPreprocess, lineSourcesExpectedSource = singleLineAsLineSource expLine expDecoder outputPreprocess,
lineSourcesOutputSource = singleLineAsLineSource outLine outDecoder outputPreprocess } lineSourcesOutputSource = singleLineAsLineSource outLine outDecoder outputPreprocess }

View File

@ -1,6 +1,7 @@
module GEval.DataSource module GEval.DataSource
(ChallengeDataSource(..), (ChallengeDataSource(..),
DataSource(..)) DataSource(..),
Filter(..))
where where
import Data.Text import Data.Text
@ -9,6 +10,8 @@ import Data.Conduit.SmartSource
import Data.Conduit.Header import Data.Conduit.Header
import GEval.Selector import GEval.Selector
newtype Filter = Filter (Maybe (Text -> Bool))
-- | This type specifies the way the challenge data (input and -- | This type specifies the way the challenge data (input and
-- expected data, but not outputs) flow into evaluation. -- expected data, but not outputs) flow into evaluation.
-- --
@ -18,7 +21,7 @@ data ChallengeDataSource = ChallengeDataSource {
challengeDataSourceExpected :: SourceSpec, challengeDataSourceExpected :: SourceSpec,
challengeDataSourceSelector :: Maybe Selector, challengeDataSourceSelector :: Maybe Selector,
challengeDataSourcePreprocess :: Text -> Text, challengeDataSourcePreprocess :: Text -> Text,
challengeDataSourceFilter :: Maybe (Text -> Bool), challengeDataSourceFilter :: Filter,
challengeDataSourceInHeader :: Maybe TabularHeader, challengeDataSourceInHeader :: Maybe TabularHeader,
challengeDataSourceOutHeader :: Maybe TabularHeader } challengeDataSourceOutHeader :: Maybe TabularHeader }