<commit_before>/*******************************************************************************
 * Copyright (c) 2014 <NAME>.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v3.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/gpl.html
 * 
 * Contributors:
 *     <NAME> - initial API and implementation
 ******************************************************************************/
package cuchaz.enigma.mapping;

import java.util.List;
import java.util.Map;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;

import cuchaz.enigma.analysis.TranslationIndex;

public class Translator {
	
	private TranslationDirection m_direction;
	private Map<String,ClassMapping> m_classes;
	private TranslationIndex m_index;
	
	private ClassNameReplacer m_classNameReplacer = new ClassNameReplacer() {
		@Override
		public String replace(String className) {
			return translateEntry(new ClassEntry(className)).getName();
		}
	};
	
	public Translator() {
		m_direction = null;
		m_classes = Maps.newHashMap();
		m_index = new TranslationIndex();
	}
	
	public Translator(TranslationDirection direction, Map<String,ClassMapping> classes, TranslationIndex index) {
		m_direction = direction;
		m_classes = classes;
		m_index = index;
	}
	
	@SuppressWarnings("unchecked")
	public <T extends Entry> T translateEntry(T entry) {
		if (entry instanceof ClassEntry) {<commit_msg>allow updates to translation index at runtime<commit_after>/*******************************************************************************
 * Copyright (c) 2014 <NAME>.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v3.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/gpl.html
 * 
 * Contributors:
 *     <NAME> - initial API and implementation
 ******************************************************************************/
package cuchaz.enigma.mapping;

import java.util.List;
import java.util.Map;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;

import cuchaz.enigma.analysis.TranslationIndex;

public class Translator {
	
	private TranslationDirection m_direction;
	private Map<String,ClassMapping> m_classes;
	private TranslationIndex m_index;
	
	private ClassNameReplacer m_classNameReplacer = new ClassNameReplacer() {
		@Override
		public String replace(String className) {
			return translateEntry(new ClassEntry(className)).getName();
		}
	};
	
	public Translator() {
		m_direction = null;
		m_classes = Maps.newHashMap();
		m_index = new TranslationIndex();
	}
	
	public Translator(TranslationDirection direction, Map<String,ClassMapping> classes, TranslationIndex index) {
		m_direction = direction;
		m_classes = classes;
		m_index = index;
	}
	
	public TranslationIndex getTranslationIndex() {
		return m_index;
	}
	
	@SuppressWarnings("unchecked")
	public <T extends Entry> T translateEntry(T entry) {
		if (entry instanceof ClassEntry) {
{'fraction_non_alphanumeric': 0.18167305236270753, 'fraction_numerical': 0.0038314176245210726, 'mean_word_length': 5.446502057613169, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2754122', 'n_tokens_mistral': 897, 'n_tokens_neox': 810, 'n_words': 235}