<commit_before>package net.elehack.gradle.science

import org.slf4j.Logger

/**
 * TeX process output handler.  Parses TeX output for errors/warnings, and defers them until after
 * the process has finished so we only print for the last run.
 */
class TexOutputHandler extends ProcessOutputHandler {
    private boolean inError = false
    private final def errorPattern = ~/^!/
    private final def warningPattern = ~/Warning:/
    private final def errLinePattern = ~/^l\.\d+/
    private ErrorOutputMode outputMode
    private List<Message> messages = new ArrayList<>()

    public TexOutputHandler(String name, ErrorOutputMode mode) {
        super(name)
        outputMode = mode ?: ErrorOutputMode.DEFAULT
    }

    @Override
    protected void handleLine(String line) {
        def level = MessageLevel.INFO
        if (inError) {
            if (line =~ errLinePattern) {
                inError = false
            }
            if (outputMode == ErrorOutputMode.IMMEDIATE) {
                method = MessageLevel.ERROR
            } else {
                messages << new Message(MessageLevel.ERROR, line)
            }
        } else if (line =~ errorPattern) {
            inError = true
            if (outputMode == ErrorOutputMode.IMMEDIATE) {
                method = MessageLevel.ERROR
            } else {
                messages << new Message(MessageLevel.ERROR, line)
            }
        } else if (line =~ warningPattern) {
            if (outputMode == ErrorOutputMode.IMMEDIATE) {
                method = MessageLevel.WARN
            } else {
                messages << new Message(MessageLevel.WARN, line)
            }
        }

        level.print(logger, line)
    }

    public void printMessages() {
        for (msg in messages) {
            switch (msg.level) {
                case WARN:
                    logger.warn msg.content
                    break;
                case ERROR:
                    logger.error msg.content
                    break;
            }
        }
    }

    private static class Message {
        final MessageLevel level
        final String content

        Message(MessageLevel lvl, String str) {
            level = lvl
            content = str
        }
    }
}<commit_msg>fix case statement in TeX output<commit_after>package net.elehack.gradle.science

import org.slf4j.Logger

/**
 * TeX process output handler.  Parses TeX output for errors/warnings, and defers them until after
 * the process has finished so we only print for the last run.
 */
class TexOutputHandler extends ProcessOutputHandler {
    private boolean inError = false
    private final def errorPattern = ~/^!/
    private final def warningPattern = ~/Warning:/
    private final def errLinePattern = ~/^l\.\d+/
    private ErrorOutputMode outputMode
    private List<Message> messages = new ArrayList<>()

    public TexOutputHandler(String name, ErrorOutputMode mode) {
        super(name)
        outputMode = mode ?: ErrorOutputMode.DEFAULT
    }

    @Override
    protected void handleLine(String line) {
        def level = MessageLevel.INFO
        if (inError) {
            if (line =~ errLinePattern) {
                inError = false
            }
            if (outputMode == ErrorOutputMode.IMMEDIATE) {
                method = MessageLevel.ERROR
            } else {
                messages << new Message(MessageLevel.ERROR, line)
            }
        } else if (line =~ errorPattern) {
            inError = true
            if (outputMode == ErrorOutputMode.IMMEDIATE) {
                method = MessageLevel.ERROR
            } else {
                messages << new Message(MessageLevel.ERROR, line)
            }
        } else if (line =~ warningPattern) {
            if (outputMode == ErrorOutputMode.IMMEDIATE) {
                method = MessageLevel.WARN
            } else {
                messages << new Message(MessageLevel.WARN, line)
            }
        }

        level.print(logger, line)
    }

    public void printMessages() {
        for (msg in messages) {
            msg.level.print(logger, msg.content)
        }
    }

    private static class Message {
        final MessageLevel level
        final String content

        Message(MessageLevel lvl, String str) {
            level = lvl
            content = str
        }
    }
}
{'fraction_non_alphanumeric': 0.07951140815856188, 'fraction_numerical': 0.0004609356994699239, 'mean_word_length': 1.7227101631116688, 'pattern_counts': {'":': 0, '<': 19, '<?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': '1222868', 'n_tokens_mistral': 1118, 'n_tokens_neox': 1081, 'n_words': 321}