What is the problem? If you already use uimafit, try JCasUtil.selectCovered() instead.
-Torsten > -----Original Message----- > From: Thomas Gruber [mailto:[email protected]] > Sent: Wednesday, April 03, 2013 12:48 PM > To: [email protected] > Subject: UIMA subiterator > > Hi, > > > > I have a problem with the subiterator and would appreciate any help on this > issue. I use uimafit 1.4.0 and uimaj-core 2.4.0 > > Subiterator in use is: > http://uima.apache.org/d/uimaj- > 2.3.1/api/org/apache/uima/cas/text/Annotation > Index.html#subiterator%28org.apache.uima.cas.text.AnnotationFS,%20bool > ean,%2 > 0boolean%29 > > > > I have an annotation "Sentence" which covers a sentence. > > Then I have an annotation "Value" which covers numerical values in a > sentence. > > > > Example: "This is sentence A with no value. This is sentence B with value > 377." causes > > - two "Sentence" annotations: "This is sentence A with no value." > and "This is sentence B with value 377." > > - one "Value" annotation: "377" > > > > Now, if I want to get all "Value" annotations of each "Sentence", I iterate > over the "Sentence"-anntotations and then use a subiterator to iterate over > all "Value"-annotations within this sentence. > > > > The problem occurs if I set the "strict" parameter to "false". In this case, > for > the first Sentence the subiterator also returns the value of the second > sentence, i.e. "377" is returned for the sentence "This is sentence A with no > value." > > Normally, according to the javadoc, only annotations should returned with > "annot < b and annot.getBegin() <= b.getBegin() <= annot.getEnd()". > > > > The (abstracted) code fragment looks as follow: > > > > Iterator<SentenceAnnotation> it = JCasUtil.iterator(myCAS, > SentenceAnnotation.class); > > > > while (it.hasNext()) { > > > > Sentence sa = it.next(); > > > > Iterator<Value> it3 = JCasUtil.iterator(sa, Value.class, false, false); > > > > while (it3.hasNext()) { > > > > Value tempAmount = it3.next(); > > > > if (tempAmount.getBegin() > sa.getEnd()) { > > System.out.println(" > -------------------------------- ERROR ------------------------- This > sentence covers > a value which is out of bounds!"); > > } > > } > > } > > > > Thank you in advance. > > Best regards, > > Thomas > > > > > >
