<commit_before>package com.github.pochi.runner.scripts.helper;

import java.io.File;
import java.io.IOException;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.nio.file.Path;
import java.nio.file.Paths;

import com.github.pochi.kunai.entries.KunaiException;
import com.github.pochi.kunai.source.DataSource;
import com.github.pochi.kunai.source.factories.DataSourceFactory;
import com.github.pochi.kunai.source.factories.DefaultDataSourceFactory;
import com.github.pochi.runner.birthmarks.io.DefaultDumper;

public class IOHelper {
    private PrintWriter out;
    private String a;

    public IOHelper(){
        this(new PrintWriter(System.out));
    }

    public IOHelper(PrintWriter out){
        this.out = out;
    }

    public DataSource open(File file) throws IOException, KunaiException{
        DataSourceFactory factory = new DefaultDataSourceFactory();
        return factory.build(file);
    }

    public DataSource open(Path path) throws IOException, KunaiException{
        DataSourceFactory factory = new DefaultDataSourceFactory();
        return factory.build(path);
    }

    public DataSource open(String path) throws IOException, KunaiException{
        return open(Paths.get(path));
    }

    public <T> void writer(String path, T set) throws IOException{
        PrintWriter out = new PrintWriter(new FileWriter(path));
        DefaultDumper dumper = new DefaultDumper(out);
        dumper.print(set);
    }
    public void writer(String path, String string) throws IOException{
        PrintWriter out = new PrintWriter(new FileWriter(path,true));
        out.print(a);
        out.close();
        a=null;
    }
    public <T> void print(T set){
        DefaultDumper dumper = new DefaultDumper(out);
        dumper.print(set);
        out.flush();
    }
   public void print(String string){
       out.println(string);
       out.flush();
   }
    public void add(String string){
        a=a+string;
    }
}
<commit_msg>re-edit commit by sagisaka<commit_after>package com.github.pochi.runner.scripts.helper;

import java.io.File;
import java.io.IOException;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.nio.file.Path;
import java.nio.file.Paths;

import com.github.pochi.kunai.entries.KunaiException;
import com.github.pochi.kunai.source.DataSource;
import com.github.pochi.kunai.source.factories.DataSourceFactory;
import com.github.pochi.kunai.source.factories.DefaultDataSourceFactory;
import com.github.pochi.runner.birthmarks.io.DefaultDumper;

public class IOHelper {
    private PrintWriter out;

    public IOHelper(){
        this(new PrintWriter(System.out));
    }

    public IOHelper(PrintWriter out){
        this.out = out;
    }

    public DataSource open(File file) throws IOException, KunaiException{
        DataSourceFactory factory = new DefaultDataSourceFactory();
        return factory.build(file);
    }

    public DataSource open(Path path) throws IOException, KunaiException{
        DataSourceFactory factory = new DefaultDataSourceFactory();
        return factory.build(path);
    }

    public DataSource open(String path) throws IOException, KunaiException{
        return open(Paths.get(path));
    }

    public <T> void writer(String path, T set) throws IOException{
        PrintWriter out = new PrintWriter(new FileWriter(path));
        DefaultDumper dumper = new DefaultDumper(out);
        dumper.print(set);
    }

    public <T> void print(T set){
        DefaultDumper dumper = new DefaultDumper(out);
        dumper.print(set);
        out.flush();
    }

    public void print(String string){
        out.println(string);
        out.flush();
    }
}

{'fraction_non_alphanumeric': 0.10106238082266412, 'fraction_numerical': 0.0, 'mean_word_length': 3.3098591549295775, 'pattern_counts': {'":': 0, '<': 7, '<?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': '4630331', 'n_tokens_mistral': 1076, 'n_tokens_neox': 1073, 'n_words': 247}