Skip to content

Commit

Permalink
modelfile as Option[InputStream]
Browse files Browse the repository at this point in the history
  • Loading branch information
EgoLaparra committed Dec 20, 2018
1 parent 4b41236 commit 5f4d00c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ object TemporalNeuralParser {
}


class TemporalNeuralParser(modelFile: InputStream =
getClass.getResourceAsStream("/org/clulab/timenorm/model/weights-improvement-22.dl4j.zip")) {
class TemporalNeuralParser(modelFile: Option[InputStream] = None) {
private type Entities = List[List[(Int, Int, String)]]
private type Properties = List[List[(Int, String, String)]]

lazy private val network: ComputationGraph = ModelSerializer.restoreComputationGraph(modelFile, false)
lazy private val network: ComputationGraph = ModelSerializer.restoreComputationGraph(
modelFile.getOrElse(this.getClass.getResourceAsStream("/org/clulab/timenorm/model/weights-improvement-22.dl4j.zip")), false)
lazy private val char2int = readDict(this.getClass.getResourceAsStream("/org/clulab/timenorm/vocab/dictionary.json"))
lazy private val operatorLabels = Source.fromInputStream(this.getClass.getResourceAsStream("/org/clulab/timenorm/label/operator.txt")).getLines.toList
lazy private val nonOperatorLabels = Source.fromInputStream(this.getClass.getResourceAsStream("/org/clulab/timenorm/label/non-operator.txt")).getLines.toList
Expand Down
3 changes: 1 addition & 2 deletions src/main/scala/org/clulab/timenorm/neural/WordToNumber.scala
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,14 @@ object WordToNumber {
try {
g += Small(w)
} catch {
case e: NoSuchElementException => {
case e: NoSuchElementException =>
if (w == "hundred" && g!=0)
g *= 100L
else {
n += g * Magnitude(w)
g = 0L
}
}
}
(n + g).toString
}
} catch {
Expand Down

0 comments on commit 5f4d00c

Please sign in to comment.