<commit_before>/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package solution;

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.Iterator;
import java.util.Map;
import java.util.Scanner;
import java.util.concurrent.TimeUnit;

/**
 * This class is a first implementation of the "Solver" abstract class. It
 * allows the user to use the "sat4j-sat.jar" program that Abdel prepared for
 * testing purpose.
 *
 * the next model.
 * @author Abdel
 */
public class SolverTestSAT4J extends Solver {
	private Process p;
	private PrintWriter stdin;
	private BufferedReader stderr;
	private BufferedReader stdout;


	public SolverTestSAT4J(String dimacsFilePath) {
		super(dimacsFilePath);
		this.p = null;
		this.stdin = null;
	}

	public SolverTestSAT4J(String dimacsFilePath,
			Map<Integer, String> literalsMap) {
		super(dimacsFilePath, literalsMap);
		this.p = null;
		this.stdin = null;
	}

	@Override
	protected Model nextModel() throws IOException {
		stdin.println("1");
		stdin.flush();
		stdin.close();
		StringBuffer br = new StringBuffer();
		String line = "";
		while ((line = stdout.readLine()) != null) {
			br.append(line + "\n");
		}

		return parseModel(br.toString().split(" "));
	}

	@Override
	protected Model parseModel(String[] rawModelOutput) {
		Model model = new Model();
		for (String rawLiteral : rawModelOutput) {
			if (getLiteralsMap() != null) {
				model.addLiteral(getLiteralsMap().get(
						Integer.parseInt(rawLiteral)));
			} else {
				model.addLiteral(rawLiteral);
			}<commit_msg>Esthetic. Added comments for various bugs<commit_after>/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package solution;

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.Iterator;
import java.util.Map;
import java.util.Scanner;
import java.util.concurrent.TimeUnit;

/**
 * This class is a first implementation of the "Solver" abstract class. It
 * allows the user to use the "sat4j-sat.jar" program that Abdel prepared for
 * testing purpose.
 *
 * the next model.
 * @author Abdel
 */
public class SolverTestSAT4J extends Solver {
	private Process p;
	private PrintWriter stdin;
	private BufferedReader stderr;
	private BufferedReader stdout;


	public SolverTestSAT4J(String dimacsFilePath) {
		super(dimacsFilePath);
		this.p = null;
		this.stdin = null;
	}

	public SolverTestSAT4J(String dimacsFilePath,
			Map<Integer, String> literalsMap) {
		super(dimacsFilePath, literalsMap);
		this.p = null;
		this.stdin = null;
	}

	@Override
	protected Model nextModel() throws IOException {
		stdin.println("1");
		stdin.flush();
		stdin.close();
		StringBuffer br = new StringBuffer();
		String line = "";
		while ((line = stdout.readLine()) != null) {
			br.append(line + "\n"); // XXX The \n goes into the parsing!
		}

		return parseModel(br.toString().split(" "));
	}

	@Override
	protected Model parseModel(String[] rawModelOutput) {
		// TODO The parser should be able to handle the "-3" (negation)
		Model model = new Model();
		for (String rawLiteral : rawModelOutput) {
			if (getLiteralsMap() != null) {
				model.addLiteral(getLiteralsMap().get(
						Integer.parseInt(rawLiteral)));
			} else {
				model.addLiteral(rawLiteral);
			}
{'fraction_non_alphanumeric': 0.11108144192256342, 'fraction_numerical': 0.002937249666221629, 'mean_word_length': 4.210013908205841, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2865585', 'n_tokens_mistral': 1242, 'n_tokens_neox': 1149, 'n_words': 343}