diff --git a/src/kdiv/Main.java b/src/kdiv/Main.java index 9d3729d502436f9f27a15d997a97966e9dd7cd43..c4de608daecc4893e42de3ef60c225380f97484c 100644 --- a/src/kdiv/Main.java +++ b/src/kdiv/Main.java @@ -1,5 +1,6 @@ package kdiv; +import java.util.HashMap; import java.util.Map; public class Main { @@ -17,13 +18,33 @@ public class Main { * - Compute the diversity with q = i */ Sample samp = new Sample(); - Map<String, Double> distrib = samp.createSampleDistribution(); - DoubleMapSimilarity<String> similarity = samp.createSampleDistance(GRAPHSEM); + Map<String, Map<String, Double>> distrib = samp.createSampleDistribution(); + Map<String, DoubleMapSimilarity<String>> similarity = new HashMap<>(); + similarity.put(UNSTRUCT, samp.createSampleDistance(UNSTRUCT)); + similarity.put(LINEAR, samp.createSampleDistance(LINEAR)); + similarity.put(GRAPHSEM, samp.createSampleDistance(GRAPHSEM)); + similarity.put(NAMESEM, samp.createSampleDistance(NAMESEM)); //For this sample data, we expect a : positive & decreasing result - for (int i = 0 ; i <= 10 ; i++) { - double diversityAti = MathUtils.diversity(distrib, similarity, i); - System.out.println("Diversity at "+ i +" is "+ diversityAti); + + + + for (Map.Entry<String, DoubleMapSimilarity<String>> distanceMatrix : similarity.entrySet()) { + String matrix_key = distanceMatrix.getKey(); + DoubleMapSimilarity<String> distanceMatrix_i = distanceMatrix.getValue(); + System.out.println("--- MATRIX : "+ matrix_key); + for (Map.Entry<String, Map<String, Double>> entry : distrib.entrySet()) { + String distrib_key = entry.getKey(); + Map<String, Double> distrib_i = entry.getValue(); + System.out.println("--- KEY : "+ distrib_key); + for (int i = 0 ; i <= 10 ; i++) { + double diversityAti = MathUtils.diversity(distrib_i, distanceMatrix_i, i); + System.out.println("Diversity at "+ i +" is "+ diversityAti); + } + } + System.out.println(); + } + } } diff --git a/src/kdiv/Sample.java b/src/kdiv/Sample.java index eea5b733e97ef4c6af9ec611fc4916f8dac7b9d4..5bd6dc5838bb590de282c2485ce7c810148c9fb8 100644 --- a/src/kdiv/Sample.java +++ b/src/kdiv/Sample.java @@ -10,16 +10,68 @@ public class Sample { * Create a sample distribution as a HashMap. For now, the sample is equidistributed * @return */ - public Map<String, Double> createSampleDistribution() { - Map<String, Double> distrib = new HashMap<>(); + public Map<String, Map<String, Double>> createSampleDistribution() { + Map<String, Map<String, Double>> distrib = new HashMap<>(); //There is (for now) only a distribution where all the ontology are equally diverse //In order to show all distribution used in the python code, we might have to do a map of map so that we can store them - distrib.put("A", 0.2); - distrib.put("B", 0.2); - distrib.put("C", 0.2); - distrib.put("D", 0.2); - distrib.put("E", 0.2); + + Map<String, Double> dist1 = new HashMap<>(); + dist1.put("A", 0.0); + dist1.put("B", 0.0); + dist1.put("C", 1.0); + dist1.put("D", 0.0); + dist1.put("E", 0.0); + distrib.put("dist1", dist1); + + Map<String, Double> dist2 = new HashMap<>(); + dist2.put("A", 0.0); + dist2.put("B", 0.5); + dist2.put("C", 0.0); + dist2.put("D", 0.5); + dist2.put("E", 0.0); + distrib.put("dist2", dist2); + + Map<String, Double> dist3 = new HashMap<>(); + dist3.put("A", 0.0); + dist3.put("B", 0.2); + dist3.put("C", 0.6); + dist3.put("D", 0.2); + dist3.put("E", 0.0); + distrib.put("dist3", dist3); + + Map<String, Double> dist4 = new HashMap<>(); + dist4.put("A", 0.1); + dist4.put("B", 0.1); + dist4.put("C", 0.6); + dist4.put("D", 0.1); + dist4.put("E", 0.1); + distrib.put("dist4", dist4); + + Map<String, Double> dist5 = new HashMap<>(); + dist5.put("A", 0.5); + dist5.put("B", 0.0); + dist5.put("C", 0.0); + dist5.put("D", 0.0); + dist5.put("E", 0.5); + distrib.put("dist5", dist5); + + Map<String, Double> dist6 = new HashMap<>(); + dist6.put("A", 0.1); + dist6.put("B", 0.2); + dist6.put("C", 0.4); + dist6.put("D", 0.2); + dist6.put("E", 0.1); + distrib.put("dist6", dist6); + + Map<String, Double> dist7 = new HashMap<>(); + dist7.put("A", 0.2); + dist7.put("B", 0.2); + dist7.put("C", 0.2); + dist7.put("D", 0.2); + dist7.put("E", 0.2); + distrib.put("dist7", dist7); + return distrib; }