Handle JSONl (for MultiLabel-F)

This commit is contained in:
Filip Gralinski 2019-02-14 19:01:53 +01:00
parent 2ea53f92c7
commit 1a9fe36a9e
2 changed files with 8 additions and 5 deletions

View File

@ -783,14 +783,17 @@ gevalCore' TokenAccuracy _ = gevalCoreWithoutInput intoTokens
| otherwise = (h, t + 1)
hitsAndTotalsAgg = CC.foldl (\(h1, t1) (h2, t2) -> (h1 + h2, t1 + t2)) (0, 0)
gevalCore' (MultiLabelFMeasure beta) _ = gevalCoreWithoutInputOnItemTargets (liftOp intoWords)
(liftOp getWords)
-- only MultiLabel-F1 handled for JSONs for the time being...
gevalCore' (MultiLabelFMeasure beta) _ = gevalCoreWithoutInputOnItemTargets (Right . intoWords)
(Right . getWords)
(getCounts (==))
countAgg
(fMeasureOnCounts beta)
where
getWords = Right . (Prelude.map unpack) . selectByStandardThreshold . parseIntoProbList
intoWords = Right . (Prelude.map unpack) . Data.Text.words
getWords (RawItemTarget t) = Prelude.map unpack $ selectByStandardThreshold $ parseIntoProbList t
getWords (PartiallyParsedItemTarget ts) = Prelude.map unpack ts
intoWords (RawItemTarget t) = Prelude.map unpack $ Data.Text.words t
intoWords (PartiallyParsedItemTarget ts) = Prelude.map unpack ts
gevalCore' MultiLabelLogLoss _ = gevalCoreWithoutInput intoWords
(Right . parseIntoProbList)

View File

@ -375,7 +375,7 @@ main = hspec $ do
runGEvalTest "charmatch-complex-compressed" `shouldReturnAlmost` 0.1923076923076923
describe "handling jsonl format" $ do
it "simple test" $
runGEvalTestExtraOptions ["-e", "expected.jsonl" ] "jsonl-simple" `shouldReturnAlmost` 0.5
runGEvalTestExtraOptions ["-e", "expected.jsonl" ] "jsonl-simple" `shouldReturnAlmost` 0.571428571428
describe "line by line mode" $ do
let sampleChallenge =
GEvalSpecification