/*******************************************************************************
 * Copyright 2017 by the Department of Informatics (University of Oslo)
 * 
 *    This file is part of the Ontology Services Toolkit 
 *
 *******************************************************************************/
package uk.ac.ox.krr.logmap2.test.overlapping;

import java.io.File;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.semanticweb.owlapi.model.OWLOntology;
import org.semanticweb.owlapi.model.OWLOntologyCreationException;

import uk.ac.ox.krr.logmap2.LogMap2_Matcher;
import uk.ac.ox.krr.logmap2.Parameters;
import uk.ac.ox.krr.logmap2.division.BasicDivision;
import uk.ac.ox.krr.logmap2.division.MatchingTask;
import uk.ac.ox.krr.logmap2.division.QualityMeasures;
import uk.ac.ox.krr.logmap2.io.LogOutput;
import uk.ac.ox.krr.logmap2.mappings.objects.MappingObjectStr;
import uk.ac.ox.krr.logmap2.oaei.reader.RDFAlignReader;
import uk.ac.ox.krr.logmap2.statistics.StatisticsTimeMappings;
import uk.ac.ox.krr.logmap2.utilities.Utilities;

/**
 * 
 * This class will evaluate the mappings generated by a given systems for a set of divisions 
 *
 * @author ernesto
 * Created on 18 Mar 2018
 *
 */
public class EvaluateSystemMappingsForDivisions extends AbstractTestDivisionAlignmentTask {

	
	
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		
		int ontopair = 0;
				
		Parameters.print_output = false;
		Parameters.print_output_always = false;
		
		LogOutput.showOutpuLog(Parameters.print_output);
		LogOutput.showOutpuLogAlways(Parameters.print_output_always);
				
		ontopair=Utilities.MOUSE2HUMAN;
		ontopair=Utilities.FMA2NCI;		
		ontopair=Utilities.FMA2SNOMED;
		ontopair=Utilities.SNOMED2NCI;
		
		//ontopair=HP2MP2016;
		//ontopair=DOID2ORDO2016;
		//ontopair=HP2MP2017;
		//ontopair=DOID2ORDO2017;
					
		
		
		//SET MATCHING CASE
		setMatchingCase(ontopair);
		//----------------------------
		
		
		

		try {
			//overlapping.createPartitionedMatchingTasks(uri1, uri2);
			
			
			//number of tasks
			//int[] num_tasks={1,2,5,10,20,50,100,200};
			//int[] num_tasks={2,5,10,20,50,75,100,125,150,175,200};
			//String[] tools={"AML", "LogMap"};
			//String[] tools={"LogMap"};
			//String[] tools={"AML2"};
			//String[] tools={"AML"};
			//String[] tools={"Mamba"};
			//String[] tools={"YAM-BIO"};
			//String[] tools={"LogMapLite"}
			
			String[] tools={"FCA_Map"};
			
			//String[] tools={"POMAP++"};
			
			//String[] tools={"SANOM"};
			
			//String[] tools={"ALOD2Vec"};
			
			
			
			//String[] tools={"GMap"};
			//String[] tools={"POMAP++", "Mamba", "SANOM2", "FCA_Map", "ALOD2Vec"};
			//String[] tools={"POMAP++", "SANOM", "FCA_Map", "ALOD2Vec"};
			//int[] num_tasks={1,2,5,10,20, 50, 100, 200};
			//%int[] num_tasks={1, 2, 5, 10};
			//int[] num_tasks={20, 50};
			//int[] num_tasks={10, 20, 50};
			int[] num_tasks={150, 200};
			
			//int[] num_tasks={2};
			
			
			
			String base_path = "/home/ejimenez-ruiz/Documents/ATI_AIDA/DivisionMatchingTask/experiments-ijcai/results/mappings/";
			
			
			Set<MappingObjectStr> mappings_RA = new HashSet<MappingObjectStr>();
			mappings_RA.addAll(loadMappingsRDF(file_gs_rdf));
			
			
			Set<MappingObjectStr> mappings = new HashSet<MappingObjectStr>();
			
			for (String tool : tools){
				
				String mappings_path;
				
				mappings_path = base_path + folder  + tool + "_division/";
					
					
				for (int j=0; j<num_tasks.length; j++){
					
					
					for (int i=0; i<num_tasks[j]; i++){
						
						
						String m_file = mappings_path + tool + "-" + num_tasks[j] +"-" + i +".rdf";
			
						//System.out.println(m_file);
						
						
						mappings.addAll(loadMappingsRDF(m_file));
						
						
					}
					
					StandardMeasures.computeStandardMeasures(mappings, mappings_RA);

					//System.out.println(tool +"\t"+ mappings.size() + "\t" + num_tasks[j]  + "\t" + StandardMeasures.getPrecision() + "\t" + StandardMeasures.getRecall()+ "\t" + StandardMeasures.getFscore());
					
					//System.out.println(StandardMeasures.getFscore());
					
					System.out.println(tool + "\t" + num_tasks[j] + "\t" + StandardMeasures.getPrecision() + "\t" + StandardMeasures.getRecall() + "\t"+ StandardMeasures.getFscore());
					
					
					mappings.clear();
					
					
						
				}
			}
			
			
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		
		
	}

	
	
	
}
