<commit_before>package com.github.sparkcaller.utils;

import java.io.*;

public class FileExtractor {

    public static String extractExecutable(String resourceFilePath) {

        if (!resourceFilePath.startsWith("/")) {
            resourceFilePath = "/" + resourceFilePath;
        }

        if (resourceFilePath == null)
            return null;

        try {
            // Read the file we're looking for
            InputStream fileStream = FileExtractor.class.getResourceAsStream(resourceFilePath);

            // Was the resource found?
            if (fileStream == null)
                return null;

            // Grab the file name
            String[] chopped = resourceFilePath.split("\\/");
            String fileName = chopped[chopped.length-1];

            // Create our temp file
            File tempFile = File.createTempFile("sparkcaller" + System.nanoTime(), fileName);

            // Delete the file on VM exit
            tempFile.deleteOnExit();

            OutputStream out = new FileOutputStream(tempFile);

            // Write the file to the temp file
            byte[] buffer = new byte[1024];
            int len = fileStream.read(buffer);
            while (len != -1) {
                out.write(buffer, 0, len);
                len = fileStream.read(buffer);<commit_msg>[Genomics]: Extract the files to the current directory instead of /tmp, as it makes it easier to keep track of the files when using Spark.<commit_after>package com.github.sparkcaller.utils;

import java.io.*;

public class FileExtractor {

    public static String extractExecutable(String resourceFilePath) {

        if (!resourceFilePath.startsWith("/")) {
            resourceFilePath = "/" + resourceFilePath;
        }

        if (resourceFilePath == null)
            return null;

        try {
            // Read the file we're looking for
            InputStream fileStream = FileExtractor.class.getResourceAsStream(resourceFilePath);

            // Was the resource found?
            if (fileStream == null)
                return null;

            // Grab the file name
            String[] chopped = resourceFilePath.split("\\/");
            String fileName = chopped[chopped.length-1];

            // Create our temp file
            File tempFile = File.createTempFile("sparkcaller" + System.nanoTime(), fileName, new File(""));

            // Delete the file on VM exit
            tempFile.deleteOnExit();

            OutputStream out = new FileOutputStream(tempFile);

            // Write the file to the temp file
            byte[] buffer = new byte[1024];
            int len = fileStream.read(buffer);
            while (len != -1) {
                out.write(buffer, 0, len);
                len = fileStream.read(buffer);
{'fraction_non_alphanumeric': 0.09707686755683868, 'fraction_numerical': 0.005052327679538073, 'mean_word_length': 1.8905109489051095, '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': '3144311', 'n_tokens_mistral': 697, 'n_tokens_neox': 652, 'n_words': 209}