<commit_before>package org.aksw.sparqlify.qa.sinks;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import org.aksw.sparqlify.qa.exceptions.NotImplementedException;
import org.aksw.sparqlify.qa.metrics.DatasetMetric;
import org.aksw.sparqlify.qa.metrics.MappingMetric;
import org.aksw.sparqlify.qa.metrics.MetricImpl;
import org.aksw.sparqlify.qa.metrics.NodeMetric;
import org.aksw.sparqlify.qa.metrics.TripleMetric;

public class ValueTestingSink implements MeasureDataSink {
	
	private HashMap<String, Float> mappingWrites;
	
	public ValueTestingSink() {
		mappingWrites = new HashMap<String, Float>();
	}

	@Override
	public void initMeasure(String name, Class<? extends MetricImpl> cls,
			String parentDimension) throws NotImplementedException {
		
		List<String> interfaceNames = new ArrayList<String>();
		
		for (Class<?> interfce : cls.getInterfaces()){
			interfaceNames.add(interfce.getName());
		}
		
		if (interfaceNames.contains(NodeMetric.class.getName())) {
			throw new NotImplementedException();
		} else if (interfaceNames.contains(TripleMetric.class.getName())) {
			throw new NotImplementedException();
		} else if (interfaceNames.contains(DatasetMetric.class.getName())) {
			throw new NotImplementedException();
		} else if (interfaceNames.contains(MappingMetric.class.getName())) {
			mappingWrites.put(name, null);
		} else {
			throw new NotImplementedException();
		}
	}


	@Override
	public void write(MeasureDatum datum) throws NotImplementedException {
		if (datum.getClass().getName().equals(NodeMeasureDatum.class.getName())) {
			throw new NotImplementedException();
		} else if (datum.getClass().getName().equals(TripleMeasureDatum.class.getName())) {
			throw new NotImplementedException();
		} else if (datum.getClass().getName().equals(DatasetMeasureDatum.class.getName())){
			throw new NotImplementedException();
		} else if (datum.getClass().getName().equals(MappingMeasureDatum.class.getName())) {
			writeMappingMeasure((MappingMeasureDatum) datum);
		} else {
			throw new NotImplementedException();
		}
	}


	private void writeMappingMeasure(MappingMeasureDatum datum) {
		mappingWrites.put(datum.getMetric(), datum.getValue());
	}


	public float mappingMeasureValue(String metricName) {
		return mappingWrites.get(metricName);
	}
}<commit_msg>added yet unimplemented dataset measure support to value test sink<commit_after>package org.aksw.sparqlify.qa.sinks;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import org.aksw.sparqlify.qa.exceptions.NotImplementedException;
import org.aksw.sparqlify.qa.metrics.DatasetMetric;
import org.aksw.sparqlify.qa.metrics.MappingMetric;
import org.aksw.sparqlify.qa.metrics.MetricImpl;
import org.aksw.sparqlify.qa.metrics.NodeMetric;
import org.aksw.sparqlify.qa.metrics.TripleMetric;

public class ValueTestingSink implements MeasureDataSink {
	
	private HashMap<String, Float> mappingWrites;
	private HashMap<String, Float> datasetWrites;
	
	public ValueTestingSink() {
		mappingWrites = new HashMap<String, Float>();
		datasetWrites = new HashMap<String, Float>();
	}

	@Override
	public void initMeasure(String name, Class<? extends MetricImpl> cls,
			String parentDimension) throws NotImplementedException {
		
		List<String> interfaceNames = new ArrayList<String>();
		
		for (Class<?> interfce : cls.getInterfaces()){
			interfaceNames.add(interfce.getName());
		}
		
		if (interfaceNames.contains(NodeMetric.class.getName())) {
			throw new NotImplementedException();
		} else if (interfaceNames.contains(TripleMetric.class.getName())) {
			throw new NotImplementedException();
		} else if (interfaceNames.contains(DatasetMetric.class.getName())) {
			datasetWrites.put(name, null);
		} else if (interfaceNames.contains(MappingMetric.class.getName())) {
			mappingWrites.put(name, null);
		} else {
			throw new NotImplementedException();
		}
	}


	@Override
	public void write(MeasureDatum datum) throws NotImplementedException {
		if (datum.getClass().getName().equals(NodeMeasureDatum.class.getName())) {
			throw new NotImplementedException();
		} else if (datum.getClass().getName().equals(TripleMeasureDatum.class.getName())) {
			throw new NotImplementedException();
		} else if (datum.getClass().getName().equals(DatasetMeasureDatum.class.getName())){
			writeDatasetMeasure((DatasetMeasureDatum) datum);
		} else if (datum.getClass().getName().equals(MappingMeasureDatum.class.getName())) {
			writeMappingMeasure((MappingMeasureDatum) datum);
		} else {
			throw new NotImplementedException();
		}
	}


	private void writeDatasetMeasure(DatasetMeasureDatum datum) {
		datasetWrites.put(datum.getMetric(), datum.getValue());
	}


	public float datasetMeasureValue(String metricName) {
		return datasetWrites.get(metricName);
	}


	private void writeMappingMeasure(MappingMeasureDatum datum) {
		mappingWrites.put(datum.getMetric(), datum.getValue());
	}


	public float mappingMeasureValue(String metricName) {
		return mappingWrites.get(metricName);
	}
}
{'fraction_non_alphanumeric': 0.12064503284889508, 'fraction_numerical': 0.0, 'mean_word_length': 5.671978751660027, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '142058', 'n_tokens_mistral': 1611, 'n_tokens_neox': 1509, 'n_words': 283}