diff options
author | bnewbold <bnewbold@archive.org> | 2018-08-23 22:55:39 +0000 |
---|---|---|
committer | bnewbold <bnewbold@archive.org> | 2018-08-23 22:55:39 +0000 |
commit | c6e9aa4226aa8ed02c80e829ddb1d3fd40103017 (patch) | |
tree | 7cadfce40b8e1873d95609bfeff41181ef5ac308 /scalding/src/main/scala/sandcrawler/GrobidScorable.scala | |
parent | 03968da99d24d81e0224712056d1dea38cb8c70e (diff) | |
parent | 6b401b34f189475efb84e72dafa2124ac50b5ee8 (diff) | |
download | sandcrawler-c6e9aa4226aa8ed02c80e829ddb1d3fd40103017.tar.gz sandcrawler-c6e9aa4226aa8ed02c80e829ddb1d3fd40103017.zip |
Merge branch 'ellen-length-filtering' into 'master'
Filtering titles by length
See merge request webgroup/sandcrawler!21
Diffstat (limited to 'scalding/src/main/scala/sandcrawler/GrobidScorable.scala')
-rw-r--r-- | scalding/src/main/scala/sandcrawler/GrobidScorable.scala | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/scalding/src/main/scala/sandcrawler/GrobidScorable.scala b/scalding/src/main/scala/sandcrawler/GrobidScorable.scala index e510f75..76f4f22 100644 --- a/scalding/src/main/scala/sandcrawler/GrobidScorable.scala +++ b/scalding/src/main/scala/sandcrawler/GrobidScorable.scala @@ -31,11 +31,27 @@ class GrobidScorable extends Scorable with HBasePipeConversions { } // TODO: Should I combine next two stages for efficiency? .collect { case (key, json, StatusOK) => (key, json) } + .filter { case (key, json) => GrobidScorable.keepRecord(json) } .map { entry : (String, String) => GrobidScorable.jsonToMapFeatures(entry._1, entry._2) } } } object GrobidScorable { + def keepRecord(json : String) : Boolean = { + Scorable.jsonToMap(json) match { + case None => false + case Some(map) => { + if (map contains "title") { + val title = Scorable.getString(map, "title") + title != null && title.length <= Scorable.MaxTitleLength + } else { + false + } + } + } + } + + def getHBaseSource(table : String, host : String) : HBaseSource = { HBaseBuilder.build(table, host, List("grobid0:metadata", "grobid0:status_code"), SourceMode.SCAN_ALL) } |