Hi,
The implementation of ByteArrayFS.toArray() doesn't look so good. As a
workaround, please try accessing the byte values one at a time using
the get(int i) method.
By the way, an easier way to get the feature should be
Feature feature = anno.getType().getFeatureByBaseName("hypernyms");
Eddie
On Fri, Sep 17, 2010 at 2:49 AM, Diman Karagiozov <[email protected]> wrote:
> Hi,
>
> I am developing an NLP tool based on latest UIMA version (2.3.0 incubating).
> Basically, the tool utilizes an aggregate engine with several primitive
> engines.
>
> Currently, I am having a problem with the handling of ByteArray values of
> one of the annotation features.
> Here is how am I setting the value of the feature:
>
> final ByteArray ba = new ByteArray( cas,
> wordHypernymsAsBytes.length );
> ba.copyFromArray( wordHypernymsAsBytes, 0, 0,
> wordHypernymsAsBytes.length );
> token.setHypernyms( ba );
>
> And here is how am I reading the ByteArray features (there will be more, so
> I need a generic way of reading them):
> List< Feature > annoFeatures =
> anno.getCAS().getJCas().getTypeSystem().getType( anno.getType().getName()
> ).getFeatures();
> Iterator< Feature > featIter = annoFeatures.iterator();
> ....
> while ( featIter.hasNext() ) {
>
> Feature feature = featIter.next();
> ...
> if ( feature.getRange().getName().equalsIgnoreCase(
> "uima.cas.ByteArray" ) ) {
>
> FeatureStructure fs = anno.getFeatureValue( feature );
>
> if ( fs != null ) {
> byte[] bytes = ( ( ByteArrayFS ) fs ).toArray();
>
> ----> here is the problem actually. The bytes array contains a single byte
> (length of the array is 1). The "setter" above is setting something much
> longer.
>
> }
> }
> }
>
> My question is how to read&write the ByteArray features?
>
> Attached you can find the serialized CAS file as well...
>
> greetings
> Diman
>