<commit_before>package teetime.stage;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

import teetime.framework.AbstractConsumerStage;
import teetime.framework.OutputPort;

import com.google.common.io.Files;

public final class FileExtensionSwitch extends AbstractConsumerStage<File> {

	private final Map<String, OutputPort<File>> fileExtensions = new HashMap<String, OutputPort<File>>();

	@Override
	protected void execute(final File file) {
		String fileExtension = Files.getFileExtension(file.getAbsolutePath());
		if (logger.isDebugEnabled()) {
			this.logger.debug("fileExtension: " + fileExtension);
		}

		OutputPort<File> outputPort = this.fileExtensions.get(fileExtension);
		outputPort.send(file);
	}

	public OutputPort<File> addFileExtension(String fileExtension) {
		if (fileExtension.startsWith(".")) {
			fileExtension = fileExtension.substring(1);
		}
		OutputPort<File> outputPort = this.createOutputPort();
		this.fileExtensions.put(fileExtension, outputPort);
		this.logger.debug("SUCCESS: Registered output port for '" + fileExtension + "'");
		return outputPort;
	}

}
<commit_msg>fixed bug in FileExtensionSwitch<commit_after>package teetime.stage;

import java.io.File;
import java.util.Map;

import teetime.framework.AbstractConsumerStage;
import teetime.framework.OutputPort;
import teetime.util.HashMapWithDefault;
import teetime.util.concurrent.hashmap.ValueFactory;

import com.google.common.io.Files;

public final class FileExtensionSwitch extends AbstractConsumerStage<File> {

	private final OutputPort<File> unknownFileExtensionOutputPort = createOutputPort();

	// BETTER use the hppc ObjectObjectMap that provide getOrDefault()
	private final Map<String, OutputPort<File>> fileExtensions = new HashMapWithDefault<String, OutputPort<File>>(new ValueFactory<OutputPort<File>>() {
		@Override
		public OutputPort<File> create() {
			return unknownFileExtensionOutputPort;
		}
	});

	@Override
	protected void execute(final File file) {
		String fileExtension = Files.getFileExtension(file.getAbsolutePath());
		if (logger.isDebugEnabled()) {
			this.logger.debug("fileExtension: " + fileExtension);
		}

		OutputPort<File> outputPort = this.fileExtensions.get(fileExtension);
		outputPort.send(file);
	}

	public OutputPort<File> addFileExtension(String fileExtension) {
		if (fileExtension.startsWith(".")) {
			fileExtension = fileExtension.substring(1);
		}
		OutputPort<File> outputPort = this.createOutputPort();
		this.fileExtensions.put(fileExtension, outputPort);
		this.logger.debug("SUCCESS: Registered output port for '" + fileExtension + "'");
		return outputPort;
	}

}

{'fraction_non_alphanumeric': 0.1125426297840091, 'fraction_numerical': 0.0007578628268283441, 'mean_word_length': 6.07774798927614, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, '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': '3103170', 'n_tokens_mistral': 796, 'n_tokens_neox': 754, 'n_words': 157}