From 78d2cd65010dba2755e45ec41e4cb06d68fac4bb Mon Sep 17 00:00:00 2001 From: Filip Gralinski Date: Wed, 13 May 2020 13:36:51 +0200 Subject: [PATCH] Add filtering operation (still not handled) --- src/GEval/EvaluationScheme.hs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/GEval/EvaluationScheme.hs b/src/GEval/EvaluationScheme.hs index d138f06..dd44eb5 100644 --- a/src/GEval/EvaluationScheme.hs +++ b/src/GEval/EvaluationScheme.hs @@ -28,6 +28,7 @@ data PreprocessingOperation = RegexpMatch Regex | SetName Text | SetPriority Int | RegexpSubstition Regex Text + | FeatureFilter Text deriving (Eq) leftParameterBracket :: Char @@ -55,6 +56,7 @@ readOps ('S':theRest) = (Sorting:ops, theRest') readOps ('N':theRest) = handleParametrizedOp (SetName . pack) theRest readOps ('P':theRest) = handleParametrizedOp (SetPriority . read) theRest readOps ('s':theRest) = handleParametrizedBinaryOp (\a b -> RegexpSubstition (fromRight undefined $ compileM (BSU.fromString a) []) (pack b)) theRest +readOps ('f':theRest) = handleParametrizedOp (FeatureFilter . pack) theRest readOps s = ([], s) handleParametrizedOp :: (String -> PreprocessingOperation) -> String -> ([PreprocessingOperation], String) @@ -117,6 +119,7 @@ instance Show PreprocessingOperation where show (SetName t) = parametrizedOperation "N" (unpack t) show (SetPriority p) = parametrizedOperation "P" (show p) show (RegexpSubstition (Regex _ regexp) s) = "s" ++ (formatParameter $ BSU.toString regexp) ++ (formatParameter $ unpack s) + show (FeatureFilter featureSpec) = parametrizedOperation "f" (unpack featureSpec) applySubstitution :: Regex -> Text -> Text -> Text applySubstitution r substitution t = @@ -150,3 +153,4 @@ applyPreprocessingOperation Sorting = Data.Text.unwords . sort . Data.Text.words applyPreprocessingOperation (SetName _) = id applyPreprocessingOperation (SetPriority _) = id applyPreprocessingOperation (RegexpSubstition regex substition) = applySubstitution regex substition +applyPreprocessingOperation (FeatureFilter _) = id