<commit_before>package org.scify.memori.helper;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * Created by pisaris on 21/12/2016.
 */
public class MemoriConfiguration {

    /**
     * Get a variable from project.properties file (given an input stream)
     * @param propertyName the name of the property
     * @return the value of the given property
     */
    public String getPropertyByName(InputStream propertyFileStream, String propertyName) {
        Properties props = new Properties();
        try {
            props.load(propertyFileStream);
            return props.getProperty(String.valueOf(propertyName));
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }

    /**
     * Given a property key, gets a value from resources/project.properties file
     * @param propertyKey the property key
     * @return the property value
     */
    public String getProjectProperty(String propertyKey) {
        //When loading a resource, the "/" means root of the main/resources directory
        InputStream inputStream = getClass().getResourceAsStream("/project_additional.properties");
        //if project_additional.properties file is not found, we load the default one
        if(inputStream == null)
            inputStream = getClass().getResourceAsStream("/project.properties");
        String propertyValue = this.getPropertyByName(inputStream, propertyKey);
        if(propertyValue == null) {
            inputStream = getClass().getResourceAsStream("/project.properties");
            propertyValue = this.getPropertyByName(inputStream, propertyKey);
        }
        return propertyValue;
    }

    /**
     * Gets the default user directory for the current architecture
     */
    public String getUserDir() {
        String userDir;
        if ((System.getProperty("os.name")).toUpperCase().contains("WINDOWS")) {
            userDir = System.getenv("AppData");
        } else {
            userDir = System.getProperty("user.dir");
        }
        return userDir + File.separator;
    }
}
<commit_msg>Refactored Class to read data from the additional pack<commit_after>package org.scify.memori.helper;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import java.util.logging.Level;

/**
 * Created by pisaris on 21/12/2016.
 */
public class MemoriConfiguration {

    /**
     * Get a variable from project.properties file (given an input stream)
     * @param propertyName the name of the property
     * @return the value of the given property
     */
    public String getPropertyByName(InputStream propertyFileStream, String propertyName) {
        Properties props = new Properties();
        try {
            props.load(propertyFileStream);
            return props.getProperty(String.valueOf(propertyName));
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }

    /**
     * Given a property key, gets a value from resources/project.properties file
     * @param propertyKey the property key
     * @return the property value
     */
    public String getProjectProperty(String propertyKey) {
        return this.getDataPackProperty(propertyKey, "/project_additional.properties");
    }

    public String getDataPackProperty(String propertyKey, String propertyFileName) {
        System.out.println("getting property file: " + propertyFileName);
        //When loading a resource, the "/" means root of the main/resources directory
        InputStream inputStream = getClass().getResourceAsStream(propertyFileName);
        //if project_additional.properties file is not found, we load the default one
        if(inputStream == null) {
            inputStream = getClass().getResourceAsStream("/project.properties");
            MemoriLogger.LOGGER.log(Level.SEVERE, "Property file: " + propertyFileName + " not found");
        }
        String propertyValue = this.getPropertyByName(inputStream, propertyKey);
        if(propertyValue == null) {
            inputStream = getClass().getResourceAsStream("/project.properties");
            propertyValue = this.getPropertyByName(inputStream, propertyKey);
        }
        return propertyValue;
    }

    /**
     * Gets the default user directory for the current architecture
     */
    public String getUserDir() {
        String userDir;
        if ((System.getProperty("os.name")).toUpperCase().contains("WINDOWS")) {
            userDir = System.getenv("AppData");
        } else {
            userDir = System.getProperty("user.dir");
        }
        return userDir + File.separator;
    }
}

{'fraction_non_alphanumeric': 0.09680152510061428, 'fraction_numerical': 0.003389112476170303, 'mean_word_length': 2.7357594936708862, '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': '6646416', 'n_tokens_mistral': 1181, 'n_tokens_neox': 1168, 'n_words': 331}