You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@uima.apache.org by Frédéric Meunier <fr...@watchsystance.com> on 2008/05/19 17:53:47 UTC

methods find, contains and compare (FSIndex class)

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


Re: methods find, contains and compare (FSIndex class)

Posted by Thilo Goetz <tw...@gmx.de>.
Frédéric Meunier wrote:
> I’m using uimaj-2.2.1-incubating and sandbox-2.2.2-10.

Don't know what you're using from the sandbox, but it
may need UIMA 2.2.2.

> 
>  
> 
> 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.

That should not be, if I understand your sample correctly.
Please open a Jira issue and provide a working test case.

Thanks,
Thilo