<commit_before>package net.happybrackets.extras.assignment_autograding;

import com.google.gson.ExclusionStrategy;
import com.google.gson.FieldAttributes;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import net.beadsproject.beads.core.AudioContext;
import net.beadsproject.beads.core.Bead;
import net.beadsproject.beads.core.UGen;
import net.beadsproject.beads.core.io.NonrealtimeIO;
import net.beadsproject.beads.ugens.*;

import java.io.*;
import java.util.Set;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Created by ollie on 27/07/2016.
 */
public class BeadsChecker {

    final static Logger logger = LoggerFactory.getLogger(BeadsChecker.class);

    public interface BeadsCheckable {
        public void task(AudioContext ac, StringBuffer buf, Object... args);
    }

    public interface BeadsCheckerFunction {
        public void runCheck(AudioContext ac, int count);
    }

    public BeadsChecker(BeadsCheckable testCode, int totalTime, int snapshotInterval, BeadsCheckerFunction func, String resultsDir) {
        File resultsDirFile = new File(resultsDir);
        if(!resultsDirFile.exists()) {
            resultsDirFile.mkdir();<commit_msg>added printToConsole(StringBuffer) method to BeadsChecker.BeadsCheckable interface<commit_after>package net.happybrackets.extras.assignment_autograding;

import com.google.gson.ExclusionStrategy;
import com.google.gson.FieldAttributes;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import net.beadsproject.beads.core.AudioContext;
import net.beadsproject.beads.core.Bead;
import net.beadsproject.beads.core.UGen;
import net.beadsproject.beads.core.io.NonrealtimeIO;
import net.beadsproject.beads.ugens.*;

import java.io.*;
import java.util.Set;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Created by ollie on 27/07/2016.
 */
public class BeadsChecker {

    final static Logger logger = LoggerFactory.getLogger(BeadsChecker.class);

    public interface BeadsCheckable {
        public void task(AudioContext ac, StringBuffer buf, Object... args);

        static void printToConsole(StringBuffer buf) { printToConsole(buf, 200); }
        static void printToConsole(StringBuffer buf, int millis) {
            new Thread(() -> {
                int bufPos = 0;
                while (true) {
                    String newText = buf.substring(bufPos);
                    bufPos += newText.length();
                    System.out.print(newText);

                    try {
                        Thread.sleep(millis);
                    } catch (InterruptedException e) {
                        return;
                    }
                }
            }).start();
        }
    }

    public interface BeadsCheckerFunction {
        public void runCheck(AudioContext ac, int count);
    }

    public BeadsChecker(BeadsCheckable testCode, int totalTime, int snapshotInterval, BeadsCheckerFunction func, String resultsDir) {
        File resultsDirFile = new File(resultsDir);
        if(!resultsDirFile.exists()) {
            resultsDirFile.mkdir();
{'fraction_non_alphanumeric': 0.09525347110106555, 'fraction_numerical': 0.007749434937035841, 'mean_word_length': 3.0077619663648125, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '4337523', 'n_tokens_mistral': 943, 'n_tokens_neox': 911, 'n_words': 192}