From dbe1613052c44f30df1df349fd048903e16f30db Mon Sep 17 00:00:00 2001 From: Filip Gralinski Date: Fri, 11 Jan 2019 08:47:11 +0100 Subject: [PATCH] Filtre out unwanted Cartesian features --- src/GEval/LineByLine.hs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/GEval/LineByLine.hs b/src/GEval/LineByLine.hs index 609b386..79e5bba 100644 --- a/src/GEval/LineByLine.hs +++ b/src/GEval/LineByLine.hs @@ -84,6 +84,7 @@ worstFeaturesPipeline :: Bool -> GEvalSpecification -> BlackBoxDebuggingOptions worstFeaturesPipeline reversed spec bbdo = rank (lessByMetric reversed $ gesMainMetric spec) .| evalStateC 0 (extractFeaturesAndPValues spec bbdo) .| gobbleAndDo (sortBy featureOrder) + .| filtreCartesian (bbdoCartesian bbdo) .| CL.map (encodeUtf8 . formatFeatureWithPValue) .| CC.unlinesAscii .| CC.stdout @@ -152,6 +153,13 @@ finalFeatures True minFreq = do $ ((Prelude.map UnaryFeature fs) ++ (cartesianFeatures $ Prelude.filter ((flip S.member) wanted) fs)) +filtreCartesian False = CC.map id +filtreCartesian True = CC.concatMapAccum step S.empty + where step f@(FeatureWithPValue (UnaryFeature p) _ _ _) mp = (S.insert p mp, [f]) + step f@(FeatureWithPValue (CartesianFeature pA pB) _ _ _) mp = (mp, if pA `S.member` mp || pB `S.member` mp + then [] + else [f]) + peggedToUnaryLine :: LineWithPeggedFeatures -> LineWithFeatures peggedToUnaryLine (LineWithPeggedFeatures rank score fs) = LineWithFeatures rank score (Prelude.map UnaryFeature fs)