<commit_before>package br.inpe.cap.evolution;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

import org.apache.commons.io.FileUtils;
import org.apache.log4j.Logger;

import br.com.metricminer2.MetricMiner2;
import br.com.metricminer2.RepositoryMining;
import br.com.metricminer2.Study;
import br.com.metricminer2.filter.range.Commits;
import br.com.metricminer2.persistence.csv.CSVFile;
import br.com.metricminer2.scm.GitRepository;
import br.inpe.cap.auxiliar.MultipleCSVFile;

public class MavenDependencyVersionEvolutionStudy implements Study {

	private static final int THREADS_FOR_REPOSITORIES = 10;
	private static final String FOUNTAIN_PATH = "fountain" + File.separator;

	private static final String STUDY_LOG_PATH = "." + File.separator + "study" + File.separator + "dependency_eval";
	private static final String EVOLUTION_LOG_PATH = STUDY_LOG_PATH + File.separator + "evolutions";
	
	private static final String FILE_PREFIX = "dependency_evolution-HOME";
	private static final String EVOLUTION_SUMMARY_CSV = STUDY_LOG_PATH + File.separator + FILE_PREFIX	+ ".csv"; 
	
	private static final File GITHUB_DONE_FILE = new File(FOUNTAIN_PATH+"done-github_evolution-HOME.txt");
	private static File EXCEPTION_FILE = new File(FOUNTAIN_PATH+"exceptions-evolution-HOME.log");
	
	private static Logger log;
	
	public static void main(String[] args) throws IOException {
		System.setProperty("logfilename", FILE_PREFIX + "_run01");
		log = Logger.getLogger(RepositoryMining.class);
		DependencyEvolutionVisitor.setLogger(log);
		
		checkRequiredLogFilesAndDirectories();
		
		new MetricMiner2().start(new MavenDependencyVersionEvolutionStudy());
		System.out.println("Finish!");
	}
	
	public void execute() {
		try {
			
			String rootRepositoriesPath = "E:\\metricminer2_studies_top20";
			List<String> gitRepoDirs = getRepositoryExceptDoneDirs(rootRepositoriesPath);

			ExecutorService execRepos = Executors.newFixedThreadPool(THREADS_FOR_REPOSITORIES);
			for(String repo : gitRepoDirs) {
				execRepos.submit(() -> 
					doMining(repo));
			}
		
			execRepos.shutdown();
			execRepos.awaitTermination(Long.MAX_VALUE, TimeUnit.DAYS);
			
		} catch (Exception e) {
			try {
				String causeMessage = "";
				if(e.getCause() != null)
					causeMessage = e.getCause().getMessage();<commit_msg>Junção de CSV após execução MetricMiner (duplica csv gerado, porém tenta garantir integridade das linhas do CSV - relacionado ao #1) <commit_after>package br.inpe.cap.evolution;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

import org.apache.commons.io.FileUtils;
import org.apache.log4j.Logger;

import br.com.metricminer2.MetricMiner2;
import br.com.metricminer2.RepositoryMining;
import br.com.metricminer2.Study;
import br.com.metricminer2.filter.range.Commits;
import br.com.metricminer2.persistence.csv.CSVFile;
import br.com.metricminer2.scm.GitRepository;
import br.inpe.cap.auxiliar.JoinSummaryCSV;
import br.inpe.cap.auxiliar.MultipleCSVFile;

public class MavenDependencyVersionEvolutionStudy implements Study {

	private static final int THREADS_FOR_REPOSITORIES = 10;
	private static final String FOUNTAIN_PATH = "fountain" + File.separator;

	private static final String STUDY_LOG_PATH = "." + File.separator + "study" + File.separator + "dependency_eval_02";
	private static final String EVOLUTION_LOG_PATH = STUDY_LOG_PATH + File.separator + "evolutions";
	
	private static final String FILE_PREFIX = "dependency_evolution-HOME";
	private static final String EVOLUTION_SUMMARY_CSV = STUDY_LOG_PATH + File.separator + FILE_PREFIX + ".csv"; 
	
	private static final File GITHUB_DONE_FILE = new File(FOUNTAIN_PATH+"done-github_evolution-HOME.txt");
	private static File EXCEPTION_FILE = new File(FOUNTAIN_PATH+"exceptions-evolution-HOME.log");
	
	private static Logger log;
	
	public static void main(String[] args) throws Exception {
		System.setProperty("logfilename", FILE_PREFIX + "_run01");
		log = Logger.getLogger(RepositoryMining.class);
		DependencyEvolutionVisitor.setLogger(log);
		
		checkRequiredLogFilesAndDirectories();
		
		new MetricMiner2().start(new MavenDependencyVersionEvolutionStudy());
		
		JoinSummaryCSV.joinSummaryCSV(EVOLUTION_LOG_PATH, new File(EVOLUTION_LOG_PATH + "_joined.csv"));
		
		System.out.println("Finish!");
	}
	
	public void execute() {
		try {
			
			String rootRepositoriesPath = "E:\\metricminer2_studies_top20";
			List<String> gitRepoDirs = getRepositoryExceptDoneDirs(rootRepositoriesPath);

			ExecutorService execRepos = Executors.newFixedThreadPool(THREADS_FOR_REPOSITORIES);
			for(String repo : gitRepoDirs) {
				execRepos.submit(() -> 
					doMining(repo));
			}
		
			execRepos.shutdown();
			execRepos.awaitTermination(Long.MAX_VALUE, TimeUnit.DAYS);
			
		} catch (Exception e) {
			try {
				String causeMessage = "";
				if(e.getCause() != null)
					causeMessage = e.getCause().getMessage();
{'fraction_non_alphanumeric': 0.10257868790291999, 'fraction_numerical': 0.006636329161926431, 'mean_word_length': 5.401699029126213, 'pattern_counts': {'":': 0, '<': 5, '<?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': '5936759', 'n_tokens_mistral': 1869, 'n_tokens_neox': 1664, 'n_words': 329}