Refactor gevalCore
This commit is contained in:
parent
709eeec4ef
commit
2ea53f92c7
@ -783,8 +783,8 @@ gevalCore' TokenAccuracy _ = gevalCoreWithoutInput intoTokens
|
|||||||
| otherwise = (h, t + 1)
|
| otherwise = (h, t + 1)
|
||||||
hitsAndTotalsAgg = CC.foldl (\(h1, t1) (h2, t2) -> (h1 + h2, t1 + t2)) (0, 0)
|
hitsAndTotalsAgg = CC.foldl (\(h1, t1) (h2, t2) -> (h1 + h2, t1 + t2)) (0, 0)
|
||||||
|
|
||||||
gevalCore' (MultiLabelFMeasure beta) _ = gevalCoreWithoutInput intoWords
|
gevalCore' (MultiLabelFMeasure beta) _ = gevalCoreWithoutInputOnItemTargets (liftOp intoWords)
|
||||||
getWords
|
(liftOp getWords)
|
||||||
(getCounts (==))
|
(getCounts (==))
|
||||||
countAgg
|
countAgg
|
||||||
(fMeasureOnCounts beta)
|
(fMeasureOnCounts beta)
|
||||||
@ -838,11 +838,28 @@ gevalCoreWithoutInput :: (MonadUnliftIO m, MonadThrow m, MonadIO m)
|
|||||||
-> LineSource (ResourceT m) -- ^ source to read the output
|
-> LineSource (ResourceT m) -- ^ source to read the output
|
||||||
-> m (MetricValue) -- ^ metric values for the output against the expected output
|
-> m (MetricValue) -- ^ metric values for the output against the expected output
|
||||||
gevalCoreWithoutInput expParser outParser itemStep aggregator finalStep expectedLineStream outLineStream =
|
gevalCoreWithoutInput expParser outParser itemStep aggregator finalStep expectedLineStream outLineStream =
|
||||||
gevalCoreGeneralized (ParserSpecWithoutInput (liftOp expParser) (liftOp outParser)) (trans itemStep) aggregator finalStep (WithoutInput expectedLineStream outLineStream)
|
gevalCoreWithoutInputOnItemTargets (liftOp expParser) (liftOp outParser) itemStep aggregator finalStep expectedLineStream outLineStream
|
||||||
|
|
||||||
|
gevalCoreWithoutInputOnItemTargets :: (MonadUnliftIO m, MonadThrow m, MonadIO m)
|
||||||
|
=> (ItemTarget -> Either String a) -- ^ parser for values in the expected output
|
||||||
|
-> (ItemTarget -> Either String b) -- ^ parser for values in the actual output
|
||||||
|
-> ((a, b) -> c) -- ^ function which combines parsed values into a single value
|
||||||
|
-- (will be launched for each item, e.g. an error/cost function
|
||||||
|
-- could be calculated here)
|
||||||
|
-> (ConduitT c Void (ResourceT m) d) -- ^ a Conduit which aggregates all the combined values into
|
||||||
|
-- a "total" value
|
||||||
|
-> (d -> Double) -- ^ function to transform the "total" value into the final score
|
||||||
|
-> LineSource (ResourceT m) -- ^ source to read the expected output
|
||||||
|
-> LineSource (ResourceT m) -- ^ source to read the output
|
||||||
|
-> m (MetricValue) -- ^ metric values for the output against the expected output
|
||||||
|
gevalCoreWithoutInputOnItemTargets expParser outParser itemStep aggregator finalStep expectedLineStream outLineStream =
|
||||||
|
gevalCoreGeneralized (ParserSpecWithoutInput expParser outParser) (trans itemStep) aggregator finalStep (WithoutInput expectedLineStream outLineStream)
|
||||||
where
|
where
|
||||||
trans :: ((a, b) -> c) -> ParsedRecord (WithoutInput m a b) -> c
|
trans :: ((a, b) -> c) -> ParsedRecord (WithoutInput m a b) -> c
|
||||||
trans step (ParsedRecordWithoutInput x y) = step (x, y)
|
trans step (ParsedRecordWithoutInput x y) = step (x, y)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
gevalCore''' :: (MonadUnliftIO m, MonadThrow m, MonadIO m) => ParserSpec (WithoutInput m a b) -> ((Word32, (a, b)) -> c) -> (ConduitT c Void (ResourceT m) d) -> (d -> Double) -> WithoutInput m a b -> m (MetricValue)
|
gevalCore''' :: (MonadUnliftIO m, MonadThrow m, MonadIO m) => ParserSpec (WithoutInput m a b) -> ((Word32, (a, b)) -> c) -> (ConduitT c Void (ResourceT m) d) -> (d -> Double) -> WithoutInput m a b -> m (MetricValue)
|
||||||
gevalCore''' parserSpec itemStep aggregator finalStep context =
|
gevalCore''' parserSpec itemStep aggregator finalStep context =
|
||||||
gevalCoreGeneralized' parserSpec (trans itemStep) aggregator finalStep context
|
gevalCoreGeneralized' parserSpec (trans itemStep) aggregator finalStep context
|
||||||
|
Loading…
Reference in New Issue
Block a user