Am 30.07.2015 um 10:53 schrieb Richard Eckart de Castilho: > Hi, > > if the JCas sub-system of the CAS is initialized, then cas.create... *does* > return JCas cover classes.
ah, thanks, learnt something new :-) Best, Peter > The problem you describe typically occurs when a CAS has been loaded from a > serialized/binary representation and the JCas system has not been initialized > subsequently. > > After loading the CAS, do something like: cas.getJCas() or > jcas.getCas().getJCas() to make sure that the JCas subsystem is set up. > > We had such a problem e.g. in the DKPro Core BinaryCasReader, but it was > fixed for version 1.6.2 [1]. > > Cheers, > > -- Richard > > [1] https://github.com/dkpro/dkpro-core/issues/413 > > On 30.07.2015, at 10:11, [email protected] wrote: > >> Hello Peter! >> >> That works but doesn't solve the underlying problem. The line is form >> DKPro's StanfordNamedEntityRecognizer. Using your solution, I get the same >> error with ClearTK-TimeML. There must be something wrong elsewhere. If I >> remember correct, Richard said that it may be the initialization of the CAS. >> Has something changed from uimaFIT 2.0.0 to 2.1.0? >> >> Best, >> Armin >> >> -----Ursprüngliche Nachricht----- >> Von: Peter Klügl [mailto:[email protected]] >> Gesendet: Donnerstag, 30. Juli 2015 09:51 >> An: [email protected] >> Betreff: Re: DKPro NamedEntity ClassCastException >> >> Hi, >> >> I would assume that you could simply use >> >> NamedEntity neAnno = new NamedEntity(jcas, 0, 1); >> >> As far as I know, cas.create... does not return JCas cover classes. >> >> Best, >> >> Peter >> >> Am 30.07.2015 um 09:41 schrieb [email protected]: >>> Hello! >>> >>> I'm getting a >>> >>> java.lang.ClassCastException: org.apache.uima.cas.impl.AnnotationImpl >>> cannot be cast to de.tudarmstadt.ukp.dkpro.core.api.ner.type.NamedEntity >>> >>> using the annotator below in a CPE. It's a Maven project using >>> >>> de.tudarmstadt.ukp.dkpro.core.stanfordnlp-gpl:1.6.1, >>> de.tudarmstadt.ukp.dkpro.core.io.text-asl:1.6.1, and >>> uimafit-core:2.1.0. >>> >>> >>> >>> import org.apache.uima.analysis_engine.AnalysisEngineProcessException; >>> import org.apache.uima.cas.CAS; >>> import org.apache.uima.cas.Type; >>> import org.apache.uima.cas.TypeSystem; >>> import org.apache.uima.fit.component.CasAnnotator_ImplBase; >>> >>> import de.tudarmstadt.ukp.dkpro.core.api.ner.type.NamedEntity; >>> >>> public class CastError extends CasAnnotator_ImplBase { >>> private Type mType; >>> >>> @Override >>> public void process(CAS cas) throws AnalysisEngineProcessException { >>> // The following line causes >>> // Caused by: java.lang.ClassCastException: >>> org.apache.uima.cas.impl.AnnotationImpl cannot be cast to >>> de.tudarmstadt.ukp.dkpro.core.api.ner.type.NamedEntity >>> NamedEntity neAnno = (NamedEntity) cas.createAnnotation(mType, >>> 0, 1); >>> } >>> >>> @Override >>> public void typeSystemInit(TypeSystem aTypeSystem) throws >>> AnalysisEngineProcessException { >>> super.typeSystemInit(aTypeSystem); >>> mType = >>> aTypeSystem.getType("de.tudarmstadt.ukp.dkpro.core.api.ner.type.Person"); >>> } >>> } >>> >>> Any ideas? >>> >>> Thanks, >>> Armin >>>
