<commit_before>from .errors import ShakespeareRuntimeError
import sys


class BasicInputManager:
    def __init__(self):
        self._input_buffer = ""

    def consume_numeric_input(self):
        try:
            self._ensure_input_buffer()
        except EOFError:
            raise ShakespeareRuntimeError("End of file encountered.")

        number_input = ""
        while self._input_buffer and self._input_buffer[0].isdigit():
            number_input += self._input_buffer[0]
            self._input_buffer = self._input_buffer[1:]

        if len(number_input) == 0:
            raise ShakespeareRuntimeError("No numeric input was given.")

        if self._input_buffer and self._input_buffer[0] == "\n":
            self._input_buffer = self._input_buffer[1:]

        return int(number_input)

    def consume_character_input(self):
        try:
            self._ensure_input_buffer()
        except EOFError:
            return -1

        value = ord(self._input_buffer[0])
        self._input_buffer = self._input_buffer[1:]
        return value

    def _ensure_input_buffer(self):
        if not self._input_buffer:<commit_msg>Fix bug with out-of-order output<commit_after>from .errors import ShakespeareRuntimeError
import sys


class BasicInputManager:
    def __init__(self):
        self._input_buffer = ""

    def consume_numeric_input(self):
        try:
            self._ensure_input_buffer()
        except EOFError:
            raise ShakespeareRuntimeError("End of file encountered.")

        number_input = ""
        while self._input_buffer and self._input_buffer[0].isdigit():
            number_input += self._input_buffer[0]
            self._input_buffer = self._input_buffer[1:]

        if len(number_input) == 0:
            raise ShakespeareRuntimeError("No numeric input was given.")

        if self._input_buffer and self._input_buffer[0] == "\n":
            self._input_buffer = self._input_buffer[1:]

        return int(number_input)

    def consume_character_input(self):
        try:
            self._ensure_input_buffer()
        except EOFError:
            return -1

        value = ord(self._input_buffer[0])
        self._input_buffer = self._input_buffer[1:]
        return value

    def _ensure_input_buffer(self):
        if not self._input_buffer:
            # We want all output that has already happened to appear before we
            # ask the user for input
            sys.stdout.flush()
{'fraction_non_alphanumeric': 0.08536585365853659, 'fraction_numerical': 0.007317073170731708, 'mean_word_length': 2.3574351978171895, 'pattern_counts': {'":': 2, '<': 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': '738916', 'n_tokens_mistral': 684, 'n_tokens_neox': 655, 'n_words': 157}