<commit_before><commit_msg>New compontent to add SegmentationUnits (usually tokens)<commit_after>package de.ustu.creta.segmentation.evaluation.util;

import org.apache.uima.UimaContext;
import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
import org.apache.uima.fit.component.JCasAnnotator_ImplBase;
import org.apache.uima.fit.descriptor.ConfigurationParameter;
import org.apache.uima.fit.factory.AnnotationFactory;
import org.apache.uima.fit.util.JCasUtil;
import org.apache.uima.jcas.JCas;
import org.apache.uima.jcas.tcas.Annotation;
import org.apache.uima.resource.ResourceInitializationException;

import de.ustu.ims.segmentation.type.SegmentationUnit;

public class SegmentationUnitAnnotator extends JCasAnnotator_ImplBase {

	public static final String PARAM_ANNOTATION_TYPE = "Annotation Type";

	@ConfigurationParameter(name = PARAM_ANNOTATION_TYPE)
	String annotationTypeName = "";
	Class<? extends Annotation> annotationType;

	@SuppressWarnings("unchecked")
	@Override
	public void initialize(final UimaContext context)
			throws ResourceInitializationException {
		super.initialize(context);
		try {
			annotationType =
					(Class<? extends Annotation>) Class
							.forName(annotationTypeName);
		} catch (ClassNotFoundException e) {
			throw new ResourceInitializationException(e);
		}
	}

	@Override
	public void process(JCas jcas) throws AnalysisEngineProcessException {
		for (Annotation anno : JCasUtil.select(jcas, annotationType)) {
			AnnotationFactory.createAnnotation(jcas, anno.getBegin(),
					anno.getEnd(), SegmentationUnit.class);
		}
	}

}
{'fraction_non_alphanumeric': 0.09314033983637508, 'fraction_numerical': 0.0, 'mean_word_length': 6.162162162162162, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4363301', 'n_tokens_mistral': 514, 'n_tokens_neox': 470, 'n_words': 87}