You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@uima.apache.org by Erik Fäßler <er...@uni-jena.de> on 2014/04/08 17:17:49 UTC

FeaturePath with FSArray

Hi all,

I have a component where a parameter is supposed to be a FeaturePath string, e.g.

/address/streetname

Another parameter would be the type name, e.g. “person”.

The component would now get an iterator over all “person” instances in the CAS and from each person geht the name of the street he or she is living in.

The problem is that “address” is actually an FSArray of type “Address”, i.e. one person can have multiple addresses. Each address has then a feature “streetname”
I am easily able to get feature values when there is no array involved or when I use built-in functions. But I can not manage to get back all my street names.
The code:

TypeSystem ts = aJCas.getTypeSystem();
Type entityType = ts.getType(entityTypeString);
FeaturePath fp = aJCas.createFeaturePath();
		

try {
	fp.initialize(“/address/streetname");
		
	FSIterator<Annotation> entityIterator = aJCas.getAnnotationIndex(entityType).iterator();
	while (entityIterator.hasNext()) {
		Annotation entity = entityIterator.next();
		String streetname = fp.getValueAsString(entity);
		System.out.println(streetname);
	}
} catch (CASException e) {
	e.printStackTrace();
}

I get an exception saying the feature “address” would be primitive. Isn’t there a way to involve arrays in feature paths? I saw the FeatureValuePath interface in the JavaDocs and it looks like it could handle arrays, but it is marked deprecated and I don’t want to write a component that could be non-functional in the future when the UIMA version is updated.

Some advice? Thank!

Regards,

Erik