<commit_before>package org.motechproject.nms.imi.it;

import org.apache.commons.codec.binary.Hex;
import org.motechproject.nms.imi.service.SettingsService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.security.DigestInputStream;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class CdrTestFileHelper {

    private final static String TEST_DATE = "20150506070809";
    private final static String TEST_OBD_FILENAME = String.format("OBD_%s.csv", TEST_DATE);
    private final static String TEST_CDR_DETAIL_FILENAME = String.format("cdrDetail_%s", TEST_OBD_FILENAME);
    private final static String TEST_CDR_SUMMARY_FILENAME = String.format("cdrSummary_%s", TEST_OBD_FILENAME);

    private static final Logger LOGGER = LoggerFactory.getLogger(CdrTestFileHelper.class);

    private SettingsService settingsService;


    public void init(SettingsService settingsService) {
        this.settingsService = settingsService;
    }


    public File cdrDirectory() {
        File userDir = new File(System.getProperty("user.home"));
        String cdrDirProp = settingsService.getSettingsFacade().getProperty("imi.cdr_file_directory");
        return new File(userDir, cdrDirProp);
    }


    public String obdFileName() {
        return TEST_OBD_FILENAME;
    }


    public String cdrSummaryFileName() {
        return TEST_CDR_SUMMARY_FILENAME;
    }


    public String cdrDetailFileName() {
        return TEST_CDR_DETAIL_FILENAME;
    }


    private void copyFile(String fileName) throws IOException {
        File dstDirectory = cdrDirectory();
        String inputFile = String.format("test-files/%s", fileName);
        BufferedReader reader = new BufferedReader(new InputStreamReader(
                getClass().getClassLoader().getResourceAsStream(inputFile)));
        File dstFile = new File(cdrDirectory(), fileName);
        if (dstDirectory.mkdirs()) {
            LOGGER.info("Created required directories for {}", dstDirectory);
        } else {
            LOGGER.info("Required directories all exist for {}", dstDirectory);
        }
        LOGGER.info("Copying {} to {}", inputFile, dstFile);
        BufferedWriter writer = new BufferedWriter(new FileWriter(dstFile));
        String s;
        while ((s = reader.readLine()) != null) {
            writer.write(s);
            writer.write("\n");
        }<commit_msg>Koshal's stuff<commit_after>package org.motechproject.nms.imi.it;

import org.apache.commons.codec.binary.Hex;
import org.motechproject.nms.imi.service.SettingsService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.security.DigestInputStream;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class CdrTestFileHelper {

    private final static String TEST_DATE = "20150506070809";
    private final static String TEST_OBD_FILENAME = String.format("OBD_%s.csv", TEST_DATE);
    private final static String TEST_CDR_DETAIL_FILENAME = String.format("cdrDetail_%s", TEST_OBD_FILENAME);
    private final static String TEST_CDR_SUMMARY_FILENAME = String.format("cdrSummary_%s", TEST_OBD_FILENAME);

    private static final Logger LOGGER = LoggerFactory.getLogger(CdrTestFileHelper.class);

    private SettingsService settingsService;


    public void init(SettingsService settingsService) {
        this.settingsService = settingsService;
    }


    public File cdrDirectory() {
        File userDir = new File(System.getProperty("user.home"));
        String cdrDirProp = settingsService.getSettingsFacade().getProperty("imi.cdr_file_directory");
        return new File(userDir, cdrDirProp);
    }


    public String obdFileName() {
        return TEST_OBD_FILENAME;
    }


    public String cdrSummaryFileName() {
        return TEST_CDR_SUMMARY_FILENAME;
    }


    public String cdrDetailFileName() {
        return TEST_CDR_DETAIL_FILENAME;
    }


    private void copyFile(String fileName) throws IOException {
        File dstDirectory = cdrDirectory();
        String inputFile = String.format("test-files/%s", fileName);
        BufferedReader reader = new BufferedReader(new InputStreamReader(
                getClass().getClassLoader().getResourceAsStream(inputFile)));
        File dstFile = new File(cdrDirectory(), fileName);
        if (dstDirectory.mkdirs()) {
            LOGGER.debug("Created required directories for {}", dstDirectory);
        } else {
            LOGGER.debug("Required directories all exist for {}", dstDirectory);
        }
        LOGGER.info("Copying {} to {}", inputFile, dstFile);
        BufferedWriter writer = new BufferedWriter(new FileWriter(dstFile));
        String s;
        while ((s = reader.readLine()) != null) {
            writer.write(s);
            writer.write("\n");
        }
{'fraction_non_alphanumeric': 0.09776162234551368, 'fraction_numerical': 0.00612205854218481, 'mean_word_length': 3.659536541889483, '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': '6203555', 'n_tokens_mistral': 1534, 'n_tokens_neox': 1471, 'n_words': 319}