<commit_before>package org.cleartk.classifier;

import java.io.File;
import java.io.IOException;
import java.util.List;

import org.apache.uima.UimaContext;
import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
import org.apache.uima.resource.ResourceInitializationException;
import org.cleartk.util.ReflectionUtil;
import org.cleartk.util.UIMAUtil;

public class DataWriterAnnotator<OUTCOME_TYPE> extends InstanceConsumer_ImplBase<OUTCOME_TYPE> {

	/**
	 * The name of the directory where the training data will be written.
	 */
	public static final String PARAM_OUTPUT_DIRECTORY = "org.cleartk.classifier.DataWriterAnnotator.PARAM_OUTPUT_DIRECTORY";
	
	public static final String PARAM_DATAWRITER_FACTORY_CLASS = "org.cleartk.classifier.DataWriterAnnotator.PARAM_DATAWRITER_FACTORY_CLASS";

	
	@Override
	public void initialize(UimaContext context) throws ResourceInitializationException {
		super.initialize(context);
		
		String outputDirectoryPath = (String) UIMAUtil.getRequiredConfigParameterValue(context, PARAM_OUTPUT_DIRECTORY);
		File outputDirectory = new File(outputDirectoryPath);

		// Instantiate the data writer
		DataWriterFactory dataWriterFactory = UIMAUtil.create(
				context, PARAM_DATAWRITER_FACTORY_CLASS, DataWriterFactory.class);
		try {
			this.dataWriter = ReflectionUtil.uncheckedCast(
					dataWriterFactory.createDataWriter(outputDirectory));
		} catch (IOException e) {
			throw new ResourceInitializationException(e);
		}
		UIMAUtil.initialize(this.dataWriter, context);
	}

	
	@Override
	public void collectionProcessComplete() throws AnalysisEngineProcessException {
		super.collectionProcessComplete();

		try {
			dataWriter.finish();
		}
		catch (IOException e) {
			throw new AnalysisEngineProcessException(e);
		}
	}

	
	public OUTCOME_TYPE consume(Instance<OUTCOME_TYPE> instance) {
		try {
			dataWriter.write(instance);
		}
		catch (IOException e) {
			throw new RuntimeException(e);
		}
		return null;
	}

	public List<?> consumeSequence(List<?> instances) {
		// TODO Auto-generated method stub
		return null;
	}

	public boolean expectsOutcomes() {
		return true;
	}
	
	private DataWriter<OUTCOME_TYPE> dataWriter;

}<commit_msg>Remove misleading (unimplemented) method from DataWriterAnnotator.<commit_after>package org.cleartk.classifier;

import java.io.File;
import java.io.IOException;
import org.apache.uima.UimaContext;
import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
import org.apache.uima.resource.ResourceInitializationException;
import org.cleartk.util.ReflectionUtil;
import org.cleartk.util.UIMAUtil;

public class DataWriterAnnotator<OUTCOME_TYPE> extends InstanceConsumer_ImplBase<OUTCOME_TYPE> {

	/**
	 * The name of the directory where the training data will be written.
	 */
	public static final String PARAM_OUTPUT_DIRECTORY = "org.cleartk.classifier.DataWriterAnnotator.PARAM_OUTPUT_DIRECTORY";
	
	public static final String PARAM_DATAWRITER_FACTORY_CLASS = "org.cleartk.classifier.DataWriterAnnotator.PARAM_DATAWRITER_FACTORY_CLASS";

	
	@Override
	public void initialize(UimaContext context) throws ResourceInitializationException {
		super.initialize(context);
		
		String outputDirectoryPath = (String) UIMAUtil.getRequiredConfigParameterValue(context, PARAM_OUTPUT_DIRECTORY);
		File outputDirectory = new File(outputDirectoryPath);

		// Instantiate the data writer
		DataWriterFactory dataWriterFactory = UIMAUtil.create(
				context, PARAM_DATAWRITER_FACTORY_CLASS, DataWriterFactory.class);
		try {
			this.dataWriter = ReflectionUtil.uncheckedCast(
					dataWriterFactory.createDataWriter(outputDirectory));
		} catch (IOException e) {
			throw new ResourceInitializationException(e);
		}
		UIMAUtil.initialize(this.dataWriter, context);
	}

	
	@Override
	public void collectionProcessComplete() throws AnalysisEngineProcessException {
		super.collectionProcessComplete();

		try {
			dataWriter.finish();
		}
		catch (IOException e) {
			throw new AnalysisEngineProcessException(e);
		}
	}

	
	public OUTCOME_TYPE consume(Instance<OUTCOME_TYPE> instance) {
		try {
			dataWriter.write(instance);
		}
		catch (IOException e) {
			throw new RuntimeException(e);
		}
		return null;
	}

	public boolean expectsOutcomes() {
		return true;
	}
	
	private DataWriter<OUTCOME_TYPE> dataWriter;

}
{'fraction_non_alphanumeric': 0.08267533673943335, 'fraction_numerical': 0.0, 'mean_word_length': 5.615975422427035, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '3102598', 'n_tokens_mistral': 1379, 'n_tokens_neox': 1267, 'n_words': 259}