vnadgir / dkpro-core-asl

Automatically exported from code.google.com/p/dkpro-core-asl
0 stars 0 forks source link

ImsCwbReader.hasNext() switches to next CAS #577

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Repeatedly calling ImsCwbReader.hasNext() has the effect of skipping through 
the complete input, even if getNext() is never called.

Original issue reported on code.google.com by richard.eckart on 19 Jan 2015 at 8:52

GoogleCodeExporter commented 9 years ago

Original comment by eriklan.dodinh@gmail.com on 27 Jan 2015 at 10:27

GoogleCodeExporter commented 9 years ago
I cannot reproduce this issue. Do you have an example test for that?

Original comment by eriklan.dodinh@gmail.com on 27 Jan 2015 at 1:24

GoogleCodeExporter commented 9 years ago
Try something like this:

JCasIterator i = SimplePipeline.iteratePipeline(imscwbreader).iterator();

while (i.hasNext()) {
  // do nothing
}

Normally, this loop should not terminate, because i.next() is never called. 
However, in my experience, it terminates.

Original comment by richard.eckart on 27 Jan 2015 at 1:47

GoogleCodeExporter commented 9 years ago
Tried that, it does not terminate for me after waiting a resonable amount of 
time (2 minutes for a 200kb file). I also tried:

JCasIterator i = SimplePipeline.iteratePipeline(imscwbreader).iterator();

int c = 0;
while (i.hasNext()) {
  c++;
  if (c == 3 || c == 100) {
    System.out.println(i.next().getDocumentText());
  }
}

It prints the first text in the file, then the second, both as expected.
Do you have an example test file, or a concrete application where this happens?

Original comment by eriklan.dodinh@gmail.com on 27 Jan 2015 at 2:11

GoogleCodeExporter commented 9 years ago
I had such a case, but I "fixed" it ;) I'll try to set one up again.

Original comment by richard.eckart on 27 Jan 2015 at 2:12

GoogleCodeExporter commented 9 years ago
Well, if you call "next", then it terminates. But repeatedly calling hasNext() 
without calling next() also terminated for me, but it shouldn't!

Original comment by richard.eckart on 27 Jan 2015 at 2:13

GoogleCodeExporter commented 9 years ago
The point was, hasNext() did not advance the iterator in my test. Also, the two 
calls to next() did expectedly not have any impact on the non-termination of my 
test, as the test-file has more than 2 texts.

Original comment by eriklan.dodinh@gmail.com on 27 Jan 2015 at 2:31

GoogleCodeExporter commented 9 years ago
Cannot reproduce it either. Looks like I misinterpreted my code and drew false 
conclusions. Sorry for the confusion.

Original comment by richard.eckart on 28 Jan 2015 at 2:21