Repository: opennlp
Updated Branches:
  refs/heads/trunk 6220e4db2 -> 92e541c93


Replace poll with remove

The remove has the same error handling as Heap.extract,
both throw an exception in case the queue runs empty
and one more element is taken from it.

The poll method return null and will make this code then
fail later.

See issue OPENNLP-879


Project: http://git-wip-us.apache.org/repos/asf/opennlp/repo
Commit: http://git-wip-us.apache.org/repos/asf/opennlp/commit/92e541c9
Tree: http://git-wip-us.apache.org/repos/asf/opennlp/tree/92e541c9
Diff: http://git-wip-us.apache.org/repos/asf/opennlp/diff/92e541c9

Branch: refs/heads/trunk
Commit: 92e541c93ea3b709de470df9d3c38c6acfa83387
Parents: 6220e4d
Author: Jörn Kottmann <[email protected]>
Authored: Mon Nov 7 19:26:14 2016 +0100
Committer: Jörn Kottmann <[email protected]>
Committed: Mon Nov 7 19:26:14 2016 +0100

----------------------------------------------------------------------
 opennlp-tools/src/main/java/opennlp/tools/ml/BeamSearch.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/opennlp/blob/92e541c9/opennlp-tools/src/main/java/opennlp/tools/ml/BeamSearch.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/main/java/opennlp/tools/ml/BeamSearch.java 
b/opennlp-tools/src/main/java/opennlp/tools/ml/BeamSearch.java
index 1395d9f..0ed5fe6 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/ml/BeamSearch.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/ml/BeamSearch.java
@@ -96,7 +96,7 @@ public class BeamSearch<T> implements 
SequenceClassificationModel<T> {
       int sz = Math.min(size, prev.size());
 
       for (int sc = 0; prev.size() > 0 && sc < sz; sc++) {
-        Sequence top = prev.poll();
+        Sequence top = prev.remove();
         List<String> tmpOutcomes = top.getOutcomes();
         String[] outcomes = tmpOutcomes.toArray(new 
String[tmpOutcomes.size()]);
         String[] contexts = cg.getContext(i, sequence, outcomes, 
additionalContext);
@@ -157,7 +157,7 @@ public class BeamSearch<T> implements 
SequenceClassificationModel<T> {
     Sequence[] topSequences = new Sequence[numSeq];
 
     for (int seqIndex = 0; seqIndex < numSeq; seqIndex++) {
-      topSequences[seqIndex] = prev.poll();
+      topSequences[seqIndex] = prev.remove();
     }
 
     return topSequences;

Reply via email to