Thanks a lot, Richard. It is working fine now after making the changes suggested by you. Looks
like I need to read up on Generics a bit...
Cheers,
Martin
> Am 02.08.2015 um 00:09 schrieb Richard Eckart de Castilho <rec@apache.org>:
>
>
> 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
|