<commit_before>package com.starkhorn.calculator;

import java.text.DecimalFormat;

import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;

public class Calculator {

	private final ScriptEngineManager scriptManager;
	private final ScriptEngine jsEngine;
	private final DecimalFormat formatter;

	public Calculator() {
		scriptManager = new ScriptEngineManager();
		jsEngine = scriptManager.getEngineByName("js");
		formatter = new DecimalFormat("0.#####");
	}

	public String run(String input) throws Throwable {
		String output = null;
		
		try {
			output = evaluate(input);
		} catch (ScriptException e) {
			output = e.getMessage();
		}
		
		return output;
	}

	private String evaluate(String input) throws ScriptException {
		String evaluated_output = jsEngine.eval(input).toString();
		Double output_number = Double.valueOf(evaluated_output);
		
		if (isInvalid(output_number)) {
			throw new ScriptException("Error: invalid input");
		}
		
		return formatter.format(output_number);
	}

	private boolean isInvalid(Double output) {
		return output.isInfinite() || output.isNaN();
	}

}
<commit_msg>Refactor variable names.<commit_after>package com.starkhorn.calculator;

import java.text.DecimalFormat;

import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;

public class Calculator {

	private final ScriptEngineManager scriptManager;
	private final ScriptEngine jsEngine;
	private final DecimalFormat formatter;

	public Calculator() {
		scriptManager = new ScriptEngineManager();
		jsEngine = scriptManager.getEngineByName("js");
		formatter = new DecimalFormat("0.#####");
	}

	public String run(String input) throws Throwable {
		String output = null;
		
		try {
			output = evaluate(input);
		} catch (ScriptException e) {
			output = e.getMessage();
		}
		
		return output;
	}

	private String evaluate(String input) throws ScriptException {
		String evaluatedOutput = jsEngine.eval(input).toString();
		Double outputNumber = Double.valueOf(evaluatedOutput);
		
		if (isInvalid(outputNumber)) {
			throw new ScriptException("Error: invalid input");
		}
		
		return formatter.format(outputNumber);
	}

	private boolean isInvalid(Double output) {
		return output.isInfinite() || output.isNaN();
	}

}

{'fraction_non_alphanumeric': 0.09785301403798513, 'fraction_numerical': 0.0008257638315441783, 'mean_word_length': 3.9448979591836735, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3517885', 'n_tokens_mistral': 751, 'n_tokens_neox': 657, 'n_words': 166}