From db177cc517eea4badf11401b72e817b75babe7aa Mon Sep 17 00:00:00 2001 From: Ellen Spertus Date: Tue, 4 Sep 2018 14:58:25 -0700 Subject: changed style of ScoreJobTest.bundle --- .../src/test/scala/sandcrawler/ScoreJobTest.scala | 24 +++++++++------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'scalding/src') diff --git a/scalding/src/test/scala/sandcrawler/ScoreJobTest.scala b/scalding/src/test/scala/sandcrawler/ScoreJobTest.scala index c3e4ff9..fbc0ee5 100644 --- a/scalding/src/test/scala/sandcrawler/ScoreJobTest.scala +++ b/scalding/src/test/scala/sandcrawler/ScoreJobTest.scala @@ -222,21 +222,17 @@ class ScoreJobTest extends FlatSpec with Matchers { } def bundle(slug : String, grobidIndex : Int, crossrefIndex : Int) : (String, Int, String, String) = { - GrobidScorable.jsonToMapFeatures( + val mfg : Option[MapFeatures] = GrobidScorable.jsonToMapFeatures( Sha1Strings(grobidIndex), - JsonStrings(grobidIndex)) match { - case None => fail() - case Some(mf1) => { - CrossrefScorable.jsonToMapFeatures(CrossrefStrings(crossrefIndex)) match { - case None => fail() - case Some(mf2) => { - val score = Scorable.computeSimilarity( - ReduceFeatures(mf1.json), - ReduceFeatures(mf2.json)) - (slug, score, mf1.json, mf2.json) - } - } - } + JsonStrings(grobidIndex)) + val mfc : Option[MapFeatures] = CrossrefScorable.jsonToMapFeatures(CrossrefStrings(crossrefIndex)) + if (mfg.isEmpty || mfc.isEmpty) { + fail() + } else { + val score = Scorable.computeSimilarity( + ReduceFeatures(mfg.get.json), + ReduceFeatures(mfc.get.json)) + (slug, score, mfg.get.json, mfc.get.json) } } -- cgit v1.2.3