From 1b7d211e587d58191c8628065e6cee991dee1698 Mon Sep 17 00:00:00 2001 From: Steven Bethard Date: Thu, 18 Jul 2019 12:32:15 -0700 Subject: [PATCH] Fixes classpath resource-loading issue. --- src/main/scala/org/clulab/geonorm/GeoNorm.scala | 8 ++++---- src/test/scala/org/clulab/geonorm/GeoNormSpec.scala | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/scala/org/clulab/geonorm/GeoNorm.scala b/src/main/scala/org/clulab/geonorm/GeoNorm.scala index b7e2390..40b3983 100644 --- a/src/main/scala/org/clulab/geonorm/GeoNorm.scala +++ b/src/main/scala/org/clulab/geonorm/GeoNorm.scala @@ -1,6 +1,6 @@ package org.clulab.geonorm -import java.io.{BufferedReader, InputStream, InputStreamReader, Reader} +import java.io.{BufferedReader, InputStream, InputStreamReader} import java.nio.file.{Files, Path} import scala.collection.JavaConverters._ @@ -34,8 +34,8 @@ object GeoLocationExtractor { } } -class GeoLocationExtractor(taggerModel: Session = GeoLocationExtractor.loadNetwork(getClass.getResourceAsStream("/org/clulab/geonorm/model/geonorm_model.pb")), - wordToIndex: Map[String, Int] = GeoLocationExtractor.loadVocabulary(getClass.getResourceAsStream("/org/clulab/geonorm/en/geoloc-extractor-vocabulary.txt"))) { +class GeoLocationExtractor(taggerModel: Session = GeoLocationExtractor.loadNetwork(classOf[GeoLocationExtractor].getResourceAsStream("/org/clulab/geonorm/model/geonorm_model.pb")), + wordToIndex: Map[String, Int] = GeoLocationExtractor.loadVocabulary(classOf[GeoLocationExtractor].getResourceAsStream("/org/clulab/geonorm/en/geoloc-extractor-vocabulary.txt"))) { lazy private val unknownInt = wordToIndex(GeoLocationExtractor.UNKNOWN_TOKEN) lazy private val paddingInt = wordToIndex(GeoLocationExtractor.PADDING_TOKEN) @@ -173,7 +173,7 @@ object GeoLocationNormalizer { class GeoLocationNormalizer(geoNamesIndex: GeoNamesIndex, - linearModel: Option[Model] = Some(GeoLocationNormalizer.loadModel(getClass.getResourceAsStream("/org/clulab/geonorm/geonames-reranker.model")))) { + linearModel: Option[Model] = Some(GeoLocationNormalizer.loadModel(classOf[GeoLocationNormalizer].getResourceAsStream("/org/clulab/geonorm/geonames-reranker.model")))) { def scoredEntries(text: String, span: (Int, Int)): Array[(GeoNamesEntry, Float)] = span match { case (start, end) => geoNamesIndex.search(text.substring(start, end)) diff --git a/src/test/scala/org/clulab/geonorm/GeoNormSpec.scala b/src/test/scala/org/clulab/geonorm/GeoNormSpec.scala index 26d682a..43f9f85 100644 --- a/src/test/scala/org/clulab/geonorm/GeoNormSpec.scala +++ b/src/test/scala/org/clulab/geonorm/GeoNormSpec.scala @@ -2,7 +2,7 @@ package org.clulab.geonorm import java.nio.file.{Files, Paths} -import org.apache.commons.io.{FileUtils, IOUtils} +import org.apache.commons.io.FileUtils import org.scalatest.{Matchers, WordSpec} class GeoNormSpec extends WordSpec with Matchers {