<commit_before>/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package net.domesdaybook.automata;

import net.domesdaybook.automata.labeler.StateCountLabeler;
import net.domesdaybook.automata.labeler.StateLabeler;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 *
 * @author <NAME>
 */
public class Utilities {


    private Utilities() {
    };


    public static List<State> getFinalStates(final State initialState) {
        Set<State> visitedStates = new HashSet<State>();
        List<State> finalStates = new ArrayList<State>();
        getAllFinalStates(initialState, visitedStates, finalStates);
        return finalStates;
    }


    private static void getAllFinalStates(final State state, final Set<State> visitedStates, final List<State> finalStates) {
        if (!visitedStates.contains(state)) {
            visitedStates.add(state);
            if (state.isFinal()) {
                finalStates.add(state);
            }
            final List<Transition> transitions = state.getTransitions();
            for (Transition transition: transitions) {
                getAllFinalStates(transition.getToState(), visitedStates, finalStates);
            }
        }
    }


    public static String toDot(final State initialState, final String title) {
        final StringBuilder builder = new StringBuilder();
        builder.append("digraph {\n");
        builder.append(String.format("label=\"%s\"\n", title));
        Set<State> visitedStates = new HashSet<State>();
        buildDot(initialState, visitedStates, builder);
        //Map<State, String> stateLabels = new HashMap<State, String>();
        //int numberOfStates = buildDot(initialState, stateLabels, builder, 0);
        builder.append("\n}");
        return builder.toString();
    }


    private static void buildDot(State state, Set<State> visitedStates, StringBuilder builder) {
        if (!visitedStates.contains(state)) {
            visitedStates.add(state);
            final String label = state.getLabel();
            final String shape = state.isFinal() ? "doublecircle" : "circle";
            builder.append(String.format("%s [label=\"%s\", shape=\"%s\"]\n", label, label, shape));

            // process its transitions:
            final List<Transition> transitions = state.getTransitions();
            for (Transition transition : transitions) {
                final State toState = transition.getToState();
                buildDot(toState, visitedStates, builder);
                final String toStateLabel = toState.getLabel();
                final String transitionLabel = transition.toString();
                builder.append(String.format("%s->%s [label=\"%s\"]\n", label, toStateLabel,transitionLabel));
            }
        }
    }


}
<commit_msg>Removed redundant code.<commit_after>/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package net.domesdaybook.automata;

import net.domesdaybook.automata.labeler.StateCountLabeler;
import net.domesdaybook.automata.labeler.StateLabeler;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 *
 * @author <NAME>
 */
public class Utilities {


    private Utilities() {
    };


    public static List<State> getFinalStates(final State initialState) {
        Set<State> visitedStates = new HashSet<State>();
        List<State> finalStates = new ArrayList<State>();
        getAllFinalStates(initialState, visitedStates, finalStates);
        return finalStates;
    }


    private static void getAllFinalStates(final State state, final Set<State> visitedStates, final List<State> finalStates) {
        if (!visitedStates.contains(state)) {
            visitedStates.add(state);
            if (state.isFinal()) {
                finalStates.add(state);
            }
            final List<Transition> transitions = state.getTransitions();
            for (Transition transition: transitions) {
                getAllFinalStates(transition.getToState(), visitedStates, finalStates);
            }
        }
    }


    public static String toDot(final State initialState, final String title) {
        final StringBuilder builder = new StringBuilder();
        builder.append("digraph {\n");
        builder.append(String.format("label=\"%s\"\n", title));
        Set<State> visitedStates = new HashSet<State>();
        buildDot(initialState, visitedStates, builder);
        builder.append("\n}");
        return builder.toString();
    }


    private static void buildDot(State state, Set<State> visitedStates, StringBuilder builder) {
        if (!visitedStates.contains(state)) {
            visitedStates.add(state);
            final String label = state.getLabel();
            final String shape = state.isFinal() ? "doublecircle" : "circle";
            builder.append(String.format("%s [label=\"%s\", shape=\"%s\"]\n", label, label, shape));

            // process its transitions:
            final List<Transition> transitions = state.getTransitions();
            for (Transition transition : transitions) {
                final State toState = transition.getToState();
                buildDot(toState, visitedStates, builder);
                final String toStateLabel = toState.getLabel();
                final String transitionLabel = transition.toString();
                builder.append(String.format("%s->%s [label=\"%s\"]\n", label, toStateLabel,transitionLabel));
            }
        }
    }


}

{'fraction_non_alphanumeric': 0.11779403890772801, 'fraction_numerical': 0.0001784758165268606, 'mean_word_length': 2.6965699208443272, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 33, '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': '6261826', 'n_tokens_mistral': 1465, 'n_tokens_neox': 1427, 'n_words': 354}