I’m using uimaj-2.2.1-incubating and sandbox-2.2.2-10.

 

Let’s have a look to the following code extract from an annotator’s process
method:

 

 

      AnnotationIndex entryIndex =
cas.getAnnotationIndex(DictionaryEntry.type);

      CountryEntry entry = new CountryEntry(cas);

      entry.setBegin(token.getBegin());

      entry.setEnd(token.getEnd());

      for (FSIterator it2 = entryIndex.iterator(); it2.isValid();) {

            int result = entryIndex.compare(it2.get(), entry);

            result = entryIndex.compare(entry, it2.get());

            it2.moveToNext();

      }

      FeatureStructure foo =entryIndex.find(entry);

      boolean found = entryIndex.contains(entry) ;

 

token is a TokenAnnotation object (cf. Sandbox WhitespaceTokenizer).

CountryEntry extends DictionaryEntry (cf.Sandbox DictionaryAnnotator).

 

It happens for a value of it2 that result is equals to 0, i.e. my entry
object is in the index.

But foo is always null and found always false.

 

Do I missed something in the javadoc :

 
boolean contains(FeatureStructure
<http://incubator.apache.org/uima/apidocs/org/apache/uima/cas/FeatureStructu
re.html>  fs)

Check if the index contains an element equal to the given feature structure
according to the ordering of the index. Note that this is in general not the
same as feature structure identity. 

 
FeatureStructure
<http://incubator.apache.org/uima/apidocs/org/apache/uima/cas/FeatureStructu
re.html>  find(FeatureStructure
<http://incubator.apache.org/uima/apidocs/org/apache/uima/cas/FeatureStructu
re.html>  fs)

Find an entry in the index equal to the given feature structure according to
the ordering of the index. Note that this is in general not the same as
feature structure identity. 

 

 

 

Regards

 

 

 

Frederic Meunier

Reply via email to