<commit_before>import java.io.OutputStream;

import javax.swing.JTextArea;
import javax.swing.text.DefaultCaret;

@SuppressWarnings("serial")
public class LearningConsole extends JTextArea {
    private OutputStream writer = new OutputStream() {
        public void write(int b) {
            LearningConsole.this.append(String.valueOf((char) b));
        }
    };

    public LearningConsole(String text, int rows, int cols) {
        super(rows, cols);
        DefaultCaret caret = (DefaultCaret)this.getCaret();
        caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
        this.append(text);
    }

    public OutputStream getStream() {
        return writer;
    }
}
<commit_msg>Sped up the writing of text to the JTextArea and (sort of) fixed the GUI hangs if there is a large amount of text written to the JTextArea at once.<commit_after>import java.io.OutputStream;

import javax.swing.JTextArea;
import javax.swing.SwingUtilities;
import javax.swing.text.DefaultCaret;

@SuppressWarnings("serial")
public class LearningConsole extends JTextArea {
    private OutputStream writer = new OutputStream() {
        StringBuffer buff = new StringBuffer();

        public void write(int b) {
            if ((char) b == '\r')
                return;
            if ((char) b == '\n') {
                final String text = buff.toString() + '\n';
                SwingUtilities.invokeLater(new Runnable() {
                    public void run() {
                        LearningConsole.this.append(text);
                    }
                });
                buff.setLength(0);
                return;
            }

            buff.append((char) b);
        }
    };

    public LearningConsole(String text, int rows, int cols) {
        super(rows, cols);
        DefaultCaret caret = (DefaultCaret) this.getCaret();
        caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
        this.append(text);
    }

    public OutputStream getStream() {
        return writer;
    }
}

{'fraction_non_alphanumeric': 0.09718172983479106, 'fraction_numerical': 0.00048590864917395527, 'mean_word_length': 2.04135893648449, 'pattern_counts': {'":': 0, '<': 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': '6579158', 'n_tokens_mistral': 564, 'n_tokens_neox': 546, 'n_words': 142}