<commit_before># coding: utf-8
from os import path
import sys
from threading import Thread
from time import sleep

HELP_TEXT = '''After each step, a prompt will be shown.
On the prompt, you can just press Enter to continue to the next step.
But you can also:
* write h then Enter: get help.
* write g PATH_TO_PNG_IMAGE then Enter: create png with graph of the current state.
* write e then Enter: run non-interactively to the end of the algorithm.
* write s then Enter: show statistics of the execution (max fringe size, visited nodes).
* write q then Enter: quit program.'''


class ConsoleViewer(object):
    def __init__(self, interactive=True):
        self.interactive = interactive

        self.last_event = ''
        self.last_event_description = ''
        self.events = []

        self.max_fringe_size = 0
        self.visited_nodes = 0

        self.current_fringe = []
        self.last_chosen = None
        self.last_is_goal = False
        self.last_expandeds = []
        self.last_successors = []

        self.successor_color = '#DD4814'
        self.fringe_color = '#20a0c0'
        self.font_size = 11

    def pause(self):
        prompt = True
        while prompt:
            prompt = False
            if self.interactive:
                option = raw_input('> ').strip()
                if option:
                    if option == 'h':
                        self.output(HELP_TEXT)
                        prompt = True
                    elif option == 'e':
                        self.interactive = False
                    elif option == 's':
                        self.output('Statistics:')
                        self.output('Max fringe size: %i' % self.max_fringe_size)
                        self.output('Visited nodes: %i' % self.visited_nodes)
                        prompt = True
                    elif option == 'q':
                        sys.exit()
                    elif option.startswith('g ') and len(option) > 2:
                        png_path = option[2:]
                        self.create_graph(png_path)
                        self.output('graph saved to %s' % png_path)
                        prompt = True
                    else:
                        self.output('Incorrect command')
                        self.output(HELP_TEXT)
                        self.pause()<commit_msg>Instance attribute added, on the future will serve to correctly display multiple runs on the viewers<commit_after># coding: utf-8
from os import path
import sys
from threading import Thread
from time import sleep

HELP_TEXT = '''After each step, a prompt will be shown.
On the prompt, you can just press Enter to continue to the next step.
But you can also:
* write h then Enter: get help.
* write g PATH_TO_PNG_IMAGE then Enter: create png with graph of the current state.
* write e then Enter: run non-interactively to the end of the algorithm.
* write s then Enter: show statistics of the execution (max fringe size, visited nodes).
* write q then Enter: quit program.'''


class ConsoleViewer(object):
    def __init__(self, interactive=True):
        self.interactive = interactive

        self.last_event = ''
        self.last_event_description = ''
        self.events = []

        self.max_fringe_size = 0
        self.visited_nodes = 0

        self.current_fringe = []
        self.last_chosen = None
        self.last_is_goal = False
        self.last_expandeds = []
        self.last_successors = []

        self.successor_color = '#DD4814'
        self.fringe_color = '#20a0c0'
        self.font_size = 11

        self.multiple_runs = False

    def pause(self):
        prompt = True
        while prompt:
            prompt = False
            if self.interactive:
                option = raw_input('> ').strip()
                if option:
                    if option == 'h':
                        self.output(HELP_TEXT)
                        prompt = True
                    elif option == 'e':
                        self.interactive = False
                    elif option == 's':
                        self.output('Statistics:')
                        self.output('Max fringe size: %i' % self.max_fringe_size)
                        self.output('Visited nodes: %i' % self.visited_nodes)
                        prompt = True
                    elif option == 'q':
                        sys.exit()
                    elif option.startswith('g ') and len(option) > 2:
                        png_path = option[2:]
                        self.create_graph(png_path)
                        self.output('graph saved to %s' % png_path)
                        prompt = True
                    else:
                        self.output('Incorrect command')
                        self.output(HELP_TEXT)
                        self.pause()
{'fraction_non_alphanumeric': 0.08300558890498862, 'fraction_numerical': 0.00620989443179466, 'mean_word_length': 1.5101298701298702, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '6857055', 'n_tokens_mistral': 1296, 'n_tokens_neox': 1202, 'n_words': 390}