File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed
src/edu/stanford/nlp/pipeline Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ public class AnnotationIterator extends AbstractIterator<Annotation> implements
2626 JSONAnnotationReader jsonReader = new JSONAnnotationReader ();
2727 String format ;
2828 int docCnt = 0 ;
29+ int limit = 0 ;
2930
3031 public AnnotationIterator (String filename ) throws IOException {
3132 this .filename = filename ;
@@ -45,6 +46,11 @@ public AnnotationIterator(String filename) throws IOException {
4546 nextDoc = readNextDocument ();
4647 }
4748
49+ public AnnotationIterator (String filename , int limit ) throws IOException {
50+ this (filename );
51+ this .limit = limit ;
52+ }
53+
4854 @ Override
4955 public boolean hasNext () {
5056 return nextDoc != null ;
@@ -68,6 +74,9 @@ public Annotation readNextDocument() {
6874 if (br == null && input == null ) {
6975 return null ;
7076 }
77+ if (limit > 0 && docCnt >= limit ) {
78+ return null ;
79+ }
7180 try {
7281 if (serializer != null ) {
7382 if (input .available () > 0 ) {
You can’t perform that action at this time.
0 commit comments