uima-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Richard Eckart de Castilho <...@apache.org>
Subject Re: Question on JCasUtil's selectCovered(...)
Date Sat, 01 Aug 2015 22:09:57 GMT

On 01.08.2015, at 23:06, Martin Wunderlich <martin_wu@gmx.net> wrote:

> Yes, I think you might be right, Richard, and that the problem is with the use of Generics.

> 
> This would be the concrete FE class: 
> 
> public class StartingPositionOfPremiseUFE<Premise> extends StartingPositionOfPropositionUFE
{
> 
>    public static String FN_STARTINGPOSITIONOFPROPOSITION = "StartingPositionOfPremise";
> 
> 	@Override
> 	List<Premise> getPropositions(JCas jcas, int start, int end) {
> 		return JCasUtil.selectCovered(jcas, Premise.class, start, end);
> 	}
> }

I don't see why you would define <Premise> here on the subclass. You would either define
a type variable on the subclass or bind a type variable on the superclass, so:

public class StartingPositionOfPremiseUFE extends StartingPositionOfPropositionUFE<Premise>

> The call to selectCovered(…) gives the described error. The method getPropositions(…)
is defined as abstract in the super-class, which looks like this: 
> 
> 
> abstract public class StartingPositionOfPropositionUFE<T extends Proposition> extends
FeatureExtractorResource_ImplBase implements ClassificationUnitFeatureExtractor{
> 	...
>    public List<Feature> extract(JCas jcas, TextClassificationUnit classificationUnit)
{
>    	List<? extends Proposition> props = (List<? extends Proposition>) getPropositions(jcas,
start, end);

Instead of <? extends Proposition>, I think you should be using <T>.

>        if( props != null && props.size() > 0) {
>        	Proposition firstProposition = props.get(0);
>        	startingPos = firstProposition.getBegin();
>        }
> 
> 	List<Feature> featList = new ArrayList<Feature>();
>        featList.add(new Feature(FN_STARTINGPOSITIONOFPROPOSITION, startingPos));
> 
>        return featList;
>    }
> 
>    abstract List<?> getPropositions(JCas jcas, int start, int end);

Again, instead of <?> I think you should be using <T>.

> }
> 
> I’ve removed the irrelevant bits to make it more concise. 

I still don't see why you would get that error though. 

Are you sure that "Premise.class" resolves to the right class here and not to another class
which accidentally has the same name?

-- Richard
Mime
View raw message