Skip to content

Commit

Permalink
Fix for #13 - add bounds check the size of the list passed into remov…
Browse files Browse the repository at this point in the history
…e conflicts
  • Loading branch information
drewfarris committed Sep 8, 2013
1 parent e4660ff commit 2b2702d
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/test/java/com/tamingtext/opennlp/NameFinderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ private void displayNames(Span[] names, String[] tokens) {

//<start id="ne-remove-conflicts"/>
private void removeConflicts(List<Annotation> allAnnotations) {
if (allAnnotations.size() < 2) return; //<co id="co.opennlp.name.earlyreturn"/>
java.util.Collections.sort(allAnnotations); //<co id="co.opennlp.name.sort"/>
List<Annotation> stack = new ArrayList<Annotation>(); //<co id="co.opennlp.name.stack"/>
stack.add(allAnnotations.get(0));
Expand Down Expand Up @@ -119,6 +120,7 @@ private void removeConflicts(List<Annotation> allAnnotations) {

/*
<calloutlist>
<callout arearefs="co.opennlp.name.earlyreturn"><para>Exit early if there will be no conflicts.</para></callout>
<callout arearefs="co.opennlp.name.sort"><para>Sort the names based on their span's start index ascending then end index decending.</para></callout>
<callout arearefs="co.opennlp.name.stack"><para>Initialize a stack to keep track of previous names.</para></callout>
<callout arearefs="co.opennlp.name.eachname2"><para>Iterate over each name.</para></callout>
Expand Down

0 comments on commit 2b2702d

Please sign in to comment.