@@ -0,0 +1,2362 @@
+package de.unistuttgart.ims.cleartkutil;%0A%0Aimport org.apache.uima.UIMAException;%0Aimport org.apache.uima.UimaContext;%0Aimport org.apache.uima.analysis_engine.AnalysisEngineProcessException;%0Aimport org.apache.uima.cas.CASException;%0Aimport org.apache.uima.cas.Feature;%0Aimport org.apache.uima.fit.component.JCasAnnotator_ImplBase;%0Aimport org.apache.uima.fit.descriptor.ConfigurationParameter;%0Aimport org.apache.uima.fit.factory.AnnotationFactory;%0Aimport org.apache.uima.fit.util.JCasUtil;%0Aimport org.apache.uima.jcas.JCas;%0Aimport org.apache.uima.jcas.tcas.Annotation;%0Aimport org.apache.uima.resource.ResourceInitializationException;%0A%0Apublic class CreateGoldView extends JCasAnnotator_ImplBase %7B%0A%0A%09public static final String PARAM_GOLD_VIEW_NAME = %22Gold View Name%22;%0A%09public static final String PARAM_GOLD_ANNOTATION_TYPE = %22Annotation Type%22;%0A%0A%09@ConfigurationParameter(name = PARAM_GOLD_VIEW_NAME)%0A%09String goldViewName;%0A%0A%09@ConfigurationParameter(name = PARAM_GOLD_ANNOTATION_TYPE)%0A%09String annotationTypeName;%0A%0A%09Class%3C? extends Annotation%3E annotationType;%0A%0A%09@SuppressWarnings(%22unchecked%22)%0A%09@Override%0A%09public void initialize(final UimaContext context) throws ResourceInitializationException %7B%0A%09%09super.initialize(context);%0A%0A%09%09try %7B%0A%09%09%09annotationType = (Class%3C? extends Annotation%3E) Class.forName(annotationTypeName);%0A%09%09%7D catch (ClassNotFoundException e) %7B%0A%09%09%09e.printStackTrace();%0A%09%09%7D%0A%09%7D%0A%0A%09@Override%0A%09public void process(JCas jcas) throws AnalysisEngineProcessException %7B%0A%09%09JCas goldView = null;%0A%09%09try %7B%0A%09%09%09goldView = jcas.createView(goldViewName);%0A%09%09%7D catch (CASException e) %7B%0A%09%09%09throw new AnalysisEngineProcessException(e);%0A%09%09%7D%0A%09%09goldView.setDocumentText(jcas.getDocumentText());%0A%0A%09%09int typeIndexId = -1;%0A%09%09for (Annotation a : JCasUtil.select(jcas, annotationType)) %7B%0A%09%09%09typeIndexId = a.getTypeIndexID();%0A%09%09%09try %7B%0A%09%09%09%09Annotation newAnnotation = AnnotationFactory.createAnnotation(goldView, a.getBegin(), a.getEnd(),%0A%09%09%09%09%09%09annotationType);%0A%09%09%09%09for (Feature f : a.getType().getFeatures()) %7B%0A%09%09%09%09%09if (f.getRange().equals(%22uima.cas.String%22)) %7B%0A%09%09%09%09%09%09newAnnotation.setStringValue(f, a.getStringValue(f));%0A%09%09%09%09%09%7D else if (f.getRange().equals(%22uima.cas.Integer%22)) %7B%0A%09%09%09%09%09%09newAnnotation.setIntValue(f, a.getIntValue(f));%0A%09%09%09%09%09%7D%0A%09%09%09%09%7D%0A%09%09%09%7D catch (UIMAException e) %7B%0A%09%09%09%09e.printStackTrace();%0A%09%09%09%7D%0A%09%09%7D%0A%09%09if (typeIndexId != -1)%0A%09%09%09jcas.removeAllExcludingSubtypes(typeIndexId);%0A%0A%09%7D%0A%0A%7D%0A

create the gold view and copy the annotations