gt:                 + "," + meanClusterCoverage + "," + adCompression + ","
context: package experiments;
  
  import java.io.File;
  import java.io.IOException;
  import java.io.PrintStream;
  import java.util.ArrayList;
  import java.util.Arrays;
  import java.util.Collection;
  import java.util.Collections;
  import java.util.HashSet;
  import java.util.List;
  import java.util.Set;
  import java.util.TreeSet;
  
  import org.coode.distance.Distance;
  import org.coode.distance.wrapping.DistanceTableObject;
  import org.coode.oppl.exceptions.OPPLException;
  import org.coode.proximitymatrix.ClusteringProximityMatrix;
  import org.coode.proximitymatrix.cluster.Cluster;
  import org.coode.proximitymatrix.cluster.ClusterDecompositionModel;
  import org.coode.proximitymatrix.cluster.ClusterStatistics;
  import org.coode.proximitymatrix.cluster.GeneralisationStatistics;
  import org.coode.proximitymatrix.cluster.GeneralisedAtomicDecomposition;
  import org.coode.proximitymatrix.cluster.GeneralisedAtomicDecompositionMetrics;
  import org.coode.utils.EntityComparator;
  import org.coode.utils.SimpleMetric;
  import org.coode.utils.owl.ClusterCreator;
  import org.coode.utils.owl.ManchesterSyntaxRenderer;
  import org.semanticweb.owlapi.model.AxiomType;
  import org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom;
  import org.semanticweb.owlapi.model.OWLAnnotationProperty;
  import org.semanticweb.owlapi.model.OWLAxiom;
  import org.semanticweb.owlapi.model.OWLDataFactory;
  import org.semanticweb.owlapi.model.OWLEntity;
  import org.semanticweb.owlapi.model.OWLOntology;
  import org.semanticweb.owlapi.model.OWLOntologyManager;
  import org.semanticweb.owlapi.util.AnnotationValueShortFormProvider;
  import org.semanticweb.owlapi.util.ShortFormProvider;
  
  /** @author eleni */
  public class ExperimentHelper {
      private static ClusterCreator clusterer;
  
      /** @param o
       *            o
       * @param distance
       *            distance
       * @param clusteringSignature
       *            clusteringSignature
       * @return cluster decompositon model
       * @throws OPPLException
       *             OPPLException */
      public static ClusterDecompositionModel<OWLEntity> startSyntacticClustering(
              OWLOntology o, Distance<OWLEntity> distance,
              Set<OWLEntity> clusteringSignature) throws OPPLException {
          OWLOntologyManager m = o.getOWLOntologyManager();
          // remove annotations
          clusterer = new ClusterCreator();
          Set<Cluster<OWLEntity>> clusters = runClustering(distance, clusteringSignature,
                  m, clusterer);
          // put annotations back in
          // m.addAxioms(o, annotationAssertions);
          ClusterDecompositionModel<OWLEntity> model = clusterer
                  .buildClusterDecompositionModel(o, clusters);
          return model;
      }
  
      /** @param o
       *            o
       * @param entailments
       *            entailments
       * @param distance
       *            distance
       * @param clusteringSignature
       *            clusteringSignature
       * @return cluster decompositon model
       * @throws OPPLException
       *             OPPLException */
      public static ClusterDecompositionModel<OWLEntity> startSemanticClustering(
              OWLOntology o, Set<OWLAxiom> entailments, Distance<OWLEntity> distance,
              Set<OWLEntity> clusteringSignature) throws OPPLException {
          OWLOntologyManager m = o.getOWLOntologyManager();
          clusterer = new ClusterCreator();
          Set<Cluster<OWLEntity>> clusters = runClustering(distance, clusteringSignature,
                  m, clusterer);
          ClusterDecompositionModel<OWLEntity> model = clusterer
                  .buildKnowledgeExplorerClusterDecompositionModel(o, entailments, m,
                          clusters);
          return model;
      }
  
      private static Set<Cluster<OWLEntity>> runClustering(Distance<OWLEntity> distance,
              Set<OWLEntity> clusteringSignature, OWLOntologyManager m,
              ClusterCreator clusterCreator) {
          Set<OWLEntity> entities = new TreeSet<OWLEntity>(new EntityComparator());
          if (clusteringSignature == null || clusteringSignature.isEmpty()) {
              for (OWLOntology ontology : m.getOntologies()) {
                  entities.addAll(ontology.getSignature());
              }
          } else {
              entities.addAll(clusteringSignature);
          }
          Set<Cluster<OWLEntity>> clusters = clusterCreator.agglomerateAll(distance,
                  entities);
          return clusters;
      }
  
      /** @param model
       *            model
       * @return clustering metrics */
      public static Collection<? extends SimpleMetric<?>> getClusteringMetrics(
              ClusterDecompositionModel<OWLEntity> model) {
          ArrayList<SimpleMetric<?>> toReturn = new ArrayList<SimpleMetric<?>>();
          GeneralisationStatistics<Cluster<OWLEntity>, OWLEntity> genStats = GeneralisationStatistics
                  .buildStatistics(model);
          int clusterNo = model.getClusterList().size();
          int numberOfGeneralisations = genStats.getNumberOfGeneralisations();
          int numberOfInstantiations = genStats.getNumberOfInstantiations();
          double meanEntitiesPerCluster = genStats.getMeanEntitiesPerCluster();
          double ratioOfGeneralisedAxioms = genStats
                  .getRatioOfGeneralisedAxiomsToTotalAxioms();
          double meanInstantiationsPerGeneralisation = genStats
                  .getMeanOWLAxiomInstantiationsPerGeneralisation();
          double meanClusterCoverage = genStats.getMeanClusterCoveragePerGeneralisation();
          toReturn.add(new SimpleMetric<Integer>("#Clusters", clusterNo));
          toReturn.add(new SimpleMetric<Integer>("#Generalisations",
                  numberOfGeneralisations));
          toReturn.add(new SimpleMetric<Integer>("#Instantiations", numberOfInstantiations));
          toReturn.add(new SimpleMetric<Double>("MeanEntitiesPerCluster",
                  meanEntitiesPerCluster));
          toReturn.add(new SimpleMetric<Double>("GeneralisedAxioms%",
                  ratioOfGeneralisedAxioms));
          toReturn.add(new SimpleMetric<Double>("MeanInstantiationsPerGeneralisation",
                  meanInstantiationsPerGeneralisation));
          toReturn.add(new SimpleMetric<Double>("MeanClusterCoverage", meanClusterCoverage));
          return toReturn;
      }
  
      /** @param gad
       *            gad
       * @return metrics */
      public static Collection<? extends SimpleMetric<?>>
              getAtomicDecompositionGeneralisedMetrics(
                      GeneralisedAtomicDecomposition<OWLEntity> gad) {
          ArrayList<SimpleMetric<?>> toReturn = new ArrayList<SimpleMetric<?>>();
          // ad compression metrics
          GeneralisedAtomicDecompositionMetrics adstats = GeneralisedAtomicDecompositionMetrics
                  .buildMetrics(gad);
          double adCompression = adstats.getAtomicDecompositionCompression();
          double meanMergedAxiomsPerGeneralisation = adstats
                  .getMeanMergedAxiomsPerGeneralisation();
          double ratioOfMergedGeneralisations = adstats.getRatioOfMergedGeneralisations();
          toReturn.add(new SimpleMetric<Double>("ADCompression", adCompression));
          toReturn.add(new SimpleMetric<Double>("MeanMergedAxiomsPerGeneralisation",
                  meanMergedAxiomsPerGeneralisation));
          toReturn.add(new SimpleMetric<Double>("ratioOfMergedGeneralisations",
                  ratioOfMergedGeneralisations));
          return toReturn;
      }
  
      /** @param out
       *            out
       * @param s
       *            s
       * @param axiomCount
       *            axiomCount
       * @param logicalAxiomCount
       *            logicalAxiomCount
       * @param entitiesNo
       *            entitiesNo
       * @param model
       *            model
       * @param gad
       *            gad */
      public static void printStats(PrintStream out, String s, int axiomCount,
              int logicalAxiomCount, int entitiesNo,
              ClusterDecompositionModel<OWLEntity> model,
              GeneralisedAtomicDecomposition<OWLEntity> gad) {
          // generalisation quality metrics
          GeneralisationStatistics<Cluster<OWLEntity>, OWLEntity> genStats = GeneralisationStatistics
                  .buildStatistics(model);
          int clusterNo = model.getClusterList().size();
          int numberOfGeneralisations = genStats.getNumberOfGeneralisations();
          int numberOfInstantiations = genStats.getNumberOfInstantiations();
          double meanEntitiesPerCluster = genStats.getMeanEntitiesPerCluster();
          double ratioOfGeneralisedAxioms = genStats
                  .getRatioOfGeneralisedAxiomsToTotalAxioms();
          double meanInstantiationsPerGeneralisation = genStats
                  .getMeanOWLAxiomInstantiationsPerGeneralisation();
          double meanClusterCoverage = genStats.getMeanClusterCoveragePerGeneralisation();
          // ad compression metrics
          GeneralisedAtomicDecompositionMetrics adstats = GeneralisedAtomicDecompositionMetrics
                  .buildMetrics(gad);
          double adCompression = adstats.getAtomicDecompositionCompression();
          double meanMergedAxiomsPerGeneralisation = adstats
                  .getMeanMergedAxiomsPerGeneralisation();
          double ratioOfMergedGeneralisations = adstats.getRatioOfMergedGeneralisations();
          out.print(s + "," + axiomCount + "," + logicalAxiomCount + "," + entitiesNo + ","
                  + clusterNo + "," + numberOfGeneralisations + ","
                  + numberOfInstantiations + "," + meanEntitiesPerCluster + ","
                  + ratioOfGeneralisedAxioms + "," + meanInstantiationsPerGeneralisation
  