Hi Richard,
thank you very much for your help!
If I use "selectCovered" it works!
But if I define type priorities the behavior is the same as described.
I have tried to define type priorities in two ways:
1.)
TypePriorities tp1 = new TypePriorities_impl();
TypePriorityList tpl = new TypePriorityList_impl();
tpl.addType(SentenceAnnotation.class.getName());
tpl.addType(Value.class.getName());
tp1.addPriorityList(tpl);
TypeSystemDescription typeSysDescr =
TypeSystemDescriptionFactory.createTypeSystemDescriptionFromPath("file:///..
./typesystem.xml");
AnalysisEngine analysisEngine =
AnalysisEngineFactory.createPrimitive(Annotator.class,typeSysDescr, tp1);
2.)
TypePriorities tp = TypePrioritiesFactory.createTypePriorities(
SentenceAnnotation.class.getName(), Value.class.getName());
AnalysisEngine analysisEngine =
AnalysisEngineFactory.createPrimitive(Annotator.class, typeSysDescr, tp);
In both cases, the not-overlapping value annotation ("377") is assigned to
sentence annotation A.
Sentence Annotations: "This is sentence A with no value. This is sentence B
with value 377."
The rest of the code you have already seen in my first post is executed
within the "process" method of the analysis engine:
analysisEngine.process(cas);
Best regards,
Thomas
Hi Thomas,
subiterators only work properly if type priorities have been configured.
You can either use selectCovered or configure type priorities.
Auto-detection of type priorities is not yet implemented in uimaFIT. See
https://issues.apache.org/jira/browse/UIMA-2533
Cheers,
-- Richard
Am 03.04.2013 um 12:48 schrieb "Thomas Gruber" <thomas.gruber@...
<http://gmane.org/get-address.php?address=thomas.gruber%2dBuPW2cDXJO3QT0dZR%
2bAlfA%40public.gmane.org> >:
> 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/Annotatio
n>
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,%20boolean,%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
|