<commit_before>package jkind.solvers;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.List;

import jkind.JKindException;
import jkind.sexp.Sexp;

public abstract class Solver {
	public abstract void initialize();
	
	public abstract void send(Sexp sexp);
	public abstract void send(StreamDecl decl);
	public abstract void send(StreamDef def);
	public abstract void send(VarDecl decl);
	
	public abstract Label weightedAssert(Sexp sexp, int weight);
	public abstract Label labelledAssert(Sexp sexp);
	public abstract void retract(Label label);
	
	public abstract Result query(Sexp sexp);
	public abstract Result maxsatQuery(Sexp sexp);
	
	public abstract void push();
	public abstract void pop();
	
	
	/** Backend */
	
	protected Process process;
	protected BufferedWriter toSolver;
	protected BufferedReader fromSolver;
	
	protected Solver(ProcessBuilder pb) {
		pb.redirectErrorStream(true);
		try {
			process = pb.start();
		} catch (IOException e) {
			throw new JKindException("Unable to start solver", e);
		}
		addShutdownHook();
		toSolver = new BufferedWriter(new OutputStreamWriter(process.getOutputStream()));
		fromSolver = new BufferedReader(new InputStreamReader(process.getInputStream()));
	}
	

	private void addShutdownHook() {
		Runtime.getRuntime().addShutdownHook(new Thread("shutdown-hook") {
			@Override
			public void run() {
				Solver.this.stop();
			}
		});
	}

	public synchronized void stop() {
		/**
		 * This must be synchronized since two threads (a Process or a shutdown
		 * hook) may try to stop the solver at the same time
		 */

		if (process != null) {
			process.destroy();
			process = null;
		}
	}
	<commit_msg>Close scratch files<commit_after>package jkind.solvers;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.List;

import jkind.JKindException;
import jkind.sexp.Sexp;

public abstract class Solver {
	public abstract void initialize();
	
	public abstract void send(Sexp sexp);
	public abstract void send(StreamDecl decl);
	public abstract void send(StreamDef def);
	public abstract void send(VarDecl decl);
	
	public abstract Label weightedAssert(Sexp sexp, int weight);
	public abstract Label labelledAssert(Sexp sexp);
	public abstract void retract(Label label);
	
	public abstract Result query(Sexp sexp);
	public abstract Result maxsatQuery(Sexp sexp);
	
	public abstract void push();
	public abstract void pop();
	
	
	/** Backend */
	
	protected Process process;
	protected BufferedWriter toSolver;
	protected BufferedReader fromSolver;
	
	protected Solver(ProcessBuilder pb) {
		pb.redirectErrorStream(true);
		try {
			process = pb.start();
		} catch (IOException e) {
			throw new JKindException("Unable to start solver", e);
		}
		addShutdownHook();
		toSolver = new BufferedWriter(new OutputStreamWriter(process.getOutputStream()));
		fromSolver = new BufferedReader(new InputStreamReader(process.getInputStream()));
	}
	

	private void addShutdownHook() {
		Runtime.getRuntime().addShutdownHook(new Thread("shutdown-hook") {
			@Override
			public void run() {
				Solver.this.stop();
			}
		});
	}

	public synchronized void stop() {
		/**
		 * This must be synchronized since two threads (a Process or a shutdown
		 * hook) may try to stop the solver at the same time
		 */

		if (process != null) {
			process.destroy();
			process = null;
		}
		
		if (debug != null) {
			debug.close();
			debug = null;
		}
	}
	
{'fraction_non_alphanumeric': 0.09867172675521822, 'fraction_numerical': 0.0, 'mean_word_length': 4.418502202643172, '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': '2537724', 'n_tokens_mistral': 1188, 'n_tokens_neox': 1063, 'n_words': 332}