<commit_before>package hu.webarticum.jsatbuilder.solver.core;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

abstract public class AbstractSolver implements Solver {

    protected volatile STATUS status = STATUS.INITIAL;

    protected List<Object> variables = new ArrayList<Object>();

    protected List<Clause> normalClauses = new ArrayList<Clause>();

    protected List<SpecialClauseWrapper> specialClauseWrappers = new ArrayList<SpecialClauseWrapper>();

    protected List<Clause> lowPriorityOptionalClauses = new ArrayList<Clause>();

    protected List<Clause> mediumPriorityOptionalClauses = new ArrayList<Clause>();

    protected List<Clause> highPriorityOptionalClauses = new ArrayList<Clause>();

    protected Model model = new Model();
    
    protected List<String> messages = new ArrayList<String>();
    
    @Override
    public void add(Clause clause) {
        normalClauses.add(clause);
        registerClauseItems(clause);
    }

    @Override
    public void addUnique(Clause clause) {
        addSpecial(clause, 1, 1);
    }

    @Override
    public void addSpecial(Clause clause, Integer minimum, Integer maximum) {
        specialClauseWrappers.add(new SpecialClauseWrapper(clause, minimum, maximum));
        registerClauseItems(clause);
    }

    @Override
    public void addOptional(Clause clause) {
        addOptional(clause, CLAUSE_PRIORITY.MEDIUM);
    }

    @Override
    public void addOptional(Clause clause, CLAUSE_PRIORITY priority) {
        switch (priority) {
            case LOW:
                lowPriorityOptionalClauses.add(clause);
                break;
            case MEDIUM:
                mediumPriorityOptionalClauses.add(clause);
                break;
            case HIGH:
                highPriorityOptionalClauses.add(clause);
                break;
            default:
                return;
        }
        registerClauseItems(clause);
    }

    @Override
    public void shuffle() {
        Collections.shuffle(variables);
        
        Collections.shuffle(normalClauses);
        for (Clause clause: normalClauses) {
            clause.shuffle();
        }
        
        Collections.shuffle(specialClauseWrappers);
        for (SpecialClauseWrapper specialClauseWrapper: specialClauseWrappers) {
            specialClauseWrapper.clause.shuffle();
        }
        
        Collections.shuffle(lowPriorityOptionalClauses);
        for (Clause clause: lowPriorityOptionalClauses) {
            clause.shuffle();
        }
        
        Collections.shuffle(mediumPriorityOptionalClauses);
        for (Clause clause: mediumPriorityOptionalClauses) {
            clause.shuffle();
        }
        
        Collections.shuffle(highPriorityOptionalClauses);
        for (Clause clause: highPriorityOptionalClauses) {
            clause.shuffle();
        }
    }
    
    @Override
    public STATUS getStatus() {
        return status;
    }

    @Override
    public Model getModel() {
        return model;
    }
    
    @Override
    public List<String> getMessages() {
        return messages;
    }
    
    @Override
    public String toString() {
        StringBuilder resultBuilder = new StringBuilder();
        
        resultBuilder.append("Solver with " + variables.size() + " item(s) {");
        resultBuilder.append(clausesToString("normal", normalClauses));
        resultBuilder.append("\n");
        resultBuilder.append(specialClauseWrappersToString("normal", specialClauseWrappers));
        resultBuilder.append("\n");
        resultBuilder.append(clausesToString("normal", lowPriorityOptionalClauses));
        resultBuilder.append("\n");
        resultBuilder.append(clausesToString("normal", mediumPriorityOptionalClauses));
        resultBuilder.append("\n");
        resultBuilder.append(clausesToString("normal", highPriorityOptionalClauses));
        
        return resultBuilder.toString();
    }

    protected String clausesToString(String name, List<Clause> clauses) {
        StringBuilder resultBuilder = new StringBuilder();
        resultBuilder.append("\n    " + name + " {");
        for (Clause clause: clauses) {
            resultBuilder.append("\n        ");
            resultBuilder.append(clause.toString());
        }
        resultBuilder.append("\n    }");
        return resultBuilder.toString();
    }
<commit_msg>Fix clause type labels in AbstractSolver.toString()<commit_after>package hu.webarticum.jsatbuilder.solver.core;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

abstract public class AbstractSolver implements Solver {

    protected volatile STATUS status = STATUS.INITIAL;

    protected List<Object> variables = new ArrayList<Object>();

    protected List<Clause> normalClauses = new ArrayList<Clause>();

    protected List<SpecialClauseWrapper> specialClauseWrappers = new ArrayList<SpecialClauseWrapper>();

    protected List<Clause> lowPriorityOptionalClauses = new ArrayList<Clause>();

    protected List<Clause> mediumPriorityOptionalClauses = new ArrayList<Clause>();

    protected List<Clause> highPriorityOptionalClauses = new ArrayList<Clause>();

    protected Model model = new Model();
    
    protected List<String> messages = new ArrayList<String>();
    
    @Override
    public void add(Clause clause) {
        normalClauses.add(clause);
        registerClauseItems(clause);
    }

    @Override
    public void addUnique(Clause clause) {
        addSpecial(clause, 1, 1);
    }

    @Override
    public void addSpecial(Clause clause, Integer minimum, Integer maximum) {
        specialClauseWrappers.add(new SpecialClauseWrapper(clause, minimum, maximum));
        registerClauseItems(clause);
    }

    @Override
    public void addOptional(Clause clause) {
        addOptional(clause, CLAUSE_PRIORITY.MEDIUM);
    }

    @Override
    public void addOptional(Clause clause, CLAUSE_PRIORITY priority) {
        switch (priority) {
            case LOW:
                lowPriorityOptionalClauses.add(clause);
                break;
            case MEDIUM:
                mediumPriorityOptionalClauses.add(clause);
                break;
            case HIGH:
                highPriorityOptionalClauses.add(clause);
                break;
            default:
                return;
        }
        registerClauseItems(clause);
    }

    @Override
    public void shuffle() {
        Collections.shuffle(variables);
        
        Collections.shuffle(normalClauses);
        for (Clause clause: normalClauses) {
            clause.shuffle();
        }
        
        Collections.shuffle(specialClauseWrappers);
        for (SpecialClauseWrapper specialClauseWrapper: specialClauseWrappers) {
            specialClauseWrapper.clause.shuffle();
        }
        
        Collections.shuffle(lowPriorityOptionalClauses);
        for (Clause clause: lowPriorityOptionalClauses) {
            clause.shuffle();
        }
        
        Collections.shuffle(mediumPriorityOptionalClauses);
        for (Clause clause: mediumPriorityOptionalClauses) {
            clause.shuffle();
        }
        
        Collections.shuffle(highPriorityOptionalClauses);
        for (Clause clause: highPriorityOptionalClauses) {
            clause.shuffle();
        }
    }
    
    @Override
    public STATUS getStatus() {
        return status;
    }

    @Override
    public Model getModel() {
        return model;
    }
    
    @Override
    public List<String> getMessages() {
        return messages;
    }
    
    @Override
    public String toString() {
        StringBuilder resultBuilder = new StringBuilder();
        
        resultBuilder.append("Solver with " + variables.size() + " item(s) {");
        resultBuilder.append(clausesToString("normal", normalClauses));
        resultBuilder.append("\n");
        resultBuilder.append(specialClauseWrappersToString("special", specialClauseWrappers));
        resultBuilder.append("\n");
        resultBuilder.append(clausesToString("low-priority", lowPriorityOptionalClauses));
        resultBuilder.append("\n");
        resultBuilder.append(clausesToString("medium-priority", mediumPriorityOptionalClauses));
        resultBuilder.append("\n");
        resultBuilder.append(clausesToString("high-priority", highPriorityOptionalClauses));
        
        return resultBuilder.toString();
    }

    protected String clausesToString(String name, List<Clause> clauses) {
        StringBuilder resultBuilder = new StringBuilder();
        resultBuilder.append("\n    " + name + " {");
        for (Clause clause: clauses) {
            resultBuilder.append("\n        ");
            resultBuilder.append(clause.toString());
        }
        resultBuilder.append("\n    }");
        return resultBuilder.toString();
    }

{'fraction_non_alphanumeric': 0.09460224057938214, 'fraction_numerical': 0.0004526422994228811, 'mean_word_length': 2.581037277147488, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 35, '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': '680991', 'n_tokens_mistral': 2217, 'n_tokens_neox': 2246, 'n_words': 447}