Skip to content

Commit

Permalink
Rewrite without null
Browse files Browse the repository at this point in the history
  • Loading branch information
kwalcock committed Jul 7, 2022
1 parent 77b7534 commit a606c62
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion main/src/main/scala/org/clulab/dynet/Eisner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,8 @@ class Eisner {
val relativeHead = scores(i).maxBy(_._2)._1.toInt
val depMod = i + 1
val depHead = if (relativeHead == 0) 0 else depMod + relativeHead
val valid = dependencies(depMod).indices.contains(depHead) && dependencies(depMod)(depHead) != null
// lift() checks the index, and Option(_) checks for nulls.
val valid = dependencies(depMod).lift(depHead).flatMap(Option(_)).isDefined
val label = if (valid) dependencies(depMod)(depHead).label else "root"
val head =
if(generateRelativeHeads) {
Expand Down

0 comments on commit a606c62

Please sign in to comment.