option -r can be used with -m
This commit is contained in:
parent
c385710719
commit
e55b8539f1
@ -69,17 +69,17 @@ runLineByLine ordering spec = runLineByLineGeneralized ordering spec consum
|
|||||||
formatScore = Data.Text.pack . printf "%f"
|
formatScore = Data.Text.pack . printf "%f"
|
||||||
|
|
||||||
runWorstFeatures :: ResultOrdering -> GEvalSpecification -> IO ()
|
runWorstFeatures :: ResultOrdering -> GEvalSpecification -> IO ()
|
||||||
runWorstFeatures ordering spec = runLineByLineGeneralized ordering' spec (worstFeaturesPipeline spec)
|
runWorstFeatures ordering spec = runLineByLineGeneralized ordering' spec (worstFeaturesPipeline False spec)
|
||||||
where ordering' = forceSomeOrdering ordering
|
where ordering' = forceSomeOrdering ordering
|
||||||
|
|
||||||
|
|
||||||
worstFeaturesPipeline :: GEvalSpecification -> ConduitT LineRecord Void (ResourceT IO) ()
|
worstFeaturesPipeline :: Bool -> GEvalSpecification -> ConduitT LineRecord Void (ResourceT IO) ()
|
||||||
worstFeaturesPipeline spec = rank (lessByMetric $ gesMainMetric spec)
|
worstFeaturesPipeline reversed spec = rank (lessByMetric reversed $ gesMainMetric spec)
|
||||||
.| evalStateC 0 extractFeaturesAndPValues
|
.| evalStateC 0 extractFeaturesAndPValues
|
||||||
.| gobbleAndDo (sortBy featureOrder)
|
.| gobbleAndDo (sortBy featureOrder)
|
||||||
.| CL.map (encodeUtf8 . formatFeatureWithPValue)
|
.| CL.map (encodeUtf8 . formatFeatureWithPValue)
|
||||||
.| CC.unlinesAscii
|
.| CC.unlinesAscii
|
||||||
.| CC.stdout
|
.| CC.stdout
|
||||||
where formatOutput (LineRecord inp exp out _ score) = Data.Text.intercalate "\t" [
|
where formatOutput (LineRecord inp exp out _ score) = Data.Text.intercalate "\t" [
|
||||||
formatScore score,
|
formatScore score,
|
||||||
escapeTabs inp,
|
escapeTabs inp,
|
||||||
@ -174,12 +174,20 @@ totalCounter = do
|
|||||||
totalCounter
|
totalCounter
|
||||||
Nothing -> return ()
|
Nothing -> return ()
|
||||||
|
|
||||||
lessByMetric :: Metric -> (LineRecord -> LineRecord -> Bool)
|
lessByMetric :: Bool -> Metric -> (LineRecord -> LineRecord -> Bool)
|
||||||
lessByMetric metric = lessByMetric' (getMetricOrdering metric)
|
lessByMetric reversed metric = lessByMetric' reversed (getMetricOrdering metric)
|
||||||
where lessByMetric' TheHigherTheBetter = (\(LineRecord _ _ _ _ scoreA) (LineRecord _ _ _ _ scoreB) ->
|
where lessByMetric' False TheHigherTheBetter =
|
||||||
scoreA < scoreB)
|
(\(LineRecord _ _ _ _ scoreA) (LineRecord _ _ _ _ scoreB) ->
|
||||||
lessByMetric' TheLowerTheBetter = (\(LineRecord _ _ _ _ scoreA) (LineRecord _ _ _ _ scoreB) ->
|
scoreA < scoreB)
|
||||||
scoreA > scoreB)
|
lessByMetric' False TheLowerTheBetter =
|
||||||
|
(\(LineRecord _ _ _ _ scoreA) (LineRecord _ _ _ _ scoreB) ->
|
||||||
|
scoreA > scoreB)
|
||||||
|
lessByMetric' True TheHigherTheBetter =
|
||||||
|
(\(LineRecord _ _ _ _ scoreA) (LineRecord _ _ _ _ scoreB) ->
|
||||||
|
scoreA > scoreB)
|
||||||
|
lessByMetric' True TheLowerTheBetter =
|
||||||
|
(\(LineRecord _ _ _ _ scoreA) (LineRecord _ _ _ _ scoreB) ->
|
||||||
|
scoreA < scoreB)
|
||||||
|
|
||||||
runLineByLineGeneralized :: ResultOrdering -> GEvalSpecification -> ConduitT LineRecord Void (ResourceT IO) a -> IO a
|
runLineByLineGeneralized :: ResultOrdering -> GEvalSpecification -> ConduitT LineRecord Void (ResourceT IO) a -> IO a
|
||||||
runLineByLineGeneralized ordering spec consum = do
|
runLineByLineGeneralized ordering spec consum = do
|
||||||
@ -216,9 +224,13 @@ runDiff ordering otherOut spec = runDiffGeneralized ordering otherOut spec consu
|
|||||||
runMostWorseningFeatures :: ResultOrdering -> FilePath -> GEvalSpecification -> IO ()
|
runMostWorseningFeatures :: ResultOrdering -> FilePath -> GEvalSpecification -> IO ()
|
||||||
runMostWorseningFeatures ordering otherOut spec = runDiffGeneralized ordering' otherOut spec consum
|
runMostWorseningFeatures ordering otherOut spec = runDiffGeneralized ordering' otherOut spec consum
|
||||||
where ordering' = forceSomeOrdering ordering
|
where ordering' = forceSomeOrdering ordering
|
||||||
|
reversed = case ordering of
|
||||||
|
KeepTheOriginalOrder -> False
|
||||||
|
FirstTheWorst -> False
|
||||||
|
FirstTheBest -> True
|
||||||
consum :: ConduitT (LineRecord, LineRecord) Void (ResourceT IO) ()
|
consum :: ConduitT (LineRecord, LineRecord) Void (ResourceT IO) ()
|
||||||
consum = CC.map prepareFakeLineRecord
|
consum = CC.map prepareFakeLineRecord
|
||||||
.| (worstFeaturesPipeline spec)
|
.| (worstFeaturesPipeline reversed spec)
|
||||||
prepareFakeLineRecord :: (LineRecord, LineRecord) -> LineRecord
|
prepareFakeLineRecord :: (LineRecord, LineRecord) -> LineRecord
|
||||||
prepareFakeLineRecord (LineRecord _ _ _ _ scorePrev, LineRecord inp exp out c score) =
|
prepareFakeLineRecord (LineRecord _ _ _ _ scorePrev, LineRecord inp exp out c score) =
|
||||||
LineRecord inp exp out c (score - scorePrev)
|
LineRecord inp exp out c (score - scorePrev)
|
||||||
|
Loading…
Reference in New Issue
Block a user