Package org.mindswap.pellet.utils

Examples of org.mindswap.pellet.utils.Timer


    }
    */
   
    /* Classify the ontology if necessary */
    if (!reasoner.isClassified()){
      Timer timerClassify = timers.startTimer( "classification" );
      reasoner.classify();
      timerClassify.stop();
      classificationTime = timerClassify.getTotal();
    }
   
    /* Maps each class to the number of instances (including direct and indirect) */
    HashMap<OWLClass, Integer> counts = new HashMap<OWLClass, Integer>();
   
    /* Maps each class to the number of direct instances */
    HashMap<OWLClass, Integer> directIndividualsCounts = new HashMap<OWLClass, Integer>();
   
    /* Maps each class to the number of indirect instances */
    HashMap<OWLClass, Integer> indirectIndividualsCounts = new HashMap<OWLClass, Integer>();   
   
    int cumulativeNumberOfInstances = 0;
    int cumulativeNumberOfDirectInstances = 0;
    int cumulativeNumberOfIndirectInstances = 0;
    double instanceRetrievalTime = 0;
   
    for (OWLClass cc : classes){
      allIndividuals = new HashSet<OWLIndividual>();
      directIndividuals = new HashSet<OWLIndividual>();
      timers.createTimer("retrieval");
     
      System.out.println(reasoner.getEquivalentClasses(cc).size());
     
      /* retrieve all individuals of the class (direct and indirect individuals) */
      Timer timerRetrieval = timers.startTimer( "retrieval" );
      allIndividuals = reasoner.getIndividuals(cc, false);
      timerRetrieval.stop();
     
      /* update instance retrieval time */
      instanceRetrievalTime += timerRetrieval.getTotal();
     
      /* retrieve all direct instances of the class */
      directIndividuals = reasoner.getIndividuals(cc, true);   
     
      /* set the number of instances (direct + indirect) of the class */
 
View Full Code Here


      /* Initialize manager used for loading the Abox */
      OWLOntologyManager manager = null;
      manager = OWLManager.createOWLOntologyManager();

      /* Rewrite Tbox T -> T' based on the current vocabulary subset */
      Timer timerApproximation = timers.startTimer( "approximation" );
      ApproximationResult approximationResult = approximation.getNextTBox();
      timerApproximation.stop();
     
      if (approximationResult != null) {
        System.out.println("Creating Tbox approximation "+runCounter);
       
        OWLOntology abox = null;
        OWLOntology approximatedTbox = null;
        OWLReasoner reasoner = null;
        int newIndividualsToAdd = 0;
       
        /* get the approximated Tbox */
        approximatedTbox = approximationResult.approximatedOntology();
     
        if (approximationResult.isOriginal()){
          /* Last run. Use original Abox to compute the baseline run */
          aboxPhysicalURI = originalAboxURI;
        }
       
        /* Load Abox into the manager */
        abox = manager.loadOntologyFromPhysicalURI(aboxPhysicalURI);
        int aboxIndividualAxiomsCount = abox.getIndividualAxioms().size();
         
        if (measureApproximationTime) {
          /* update time with the time it takes to build the Tbox based on the current vocabulary set */
          approximationTime = timerApproximation.getTotal();
        }
     
        //OWLOntology currentTBox2 = approximationResult.approximatedOntology();
       
        /* Create a new physical URI based on the current run */
        URI tboxPhysicalURI = createNewURI(tmpTboxPhysicalURI, runCounter);
        if (saveApproximatedTbox){
          /* Save approximated Tbox to disk - for debugging purposes only */
          saveOntologyToFile(approximatedTbox, tboxPhysicalURI);
        }     
       
        /* Create the reasoner */
        reasoner = reasonerFactory.createReasoner(manager);
        logger.info("Using reasoner: "+reasonerFactory.getReasonerName());
       
        Set<OWLOntology> ontologiesToLoad = new HashSet<OWLOntology>();
        ontologiesToLoad.add(abox);
        ontologiesToLoad.add(approximatedTbox);
       
        /* Load approximated Tbox into the reasoner */
        //reasoner.loadOntologies(ontologiesToLoad);

        /* Load approximated Tbox into reasoner */
        reasoner.loadOntologies(Collections.singleton(approximatedTbox));
       
        /* Print statistics */
        printStatistics(runCounter, approximation, approximatedTbox, abox, aboxPhysicalURI);
       
        /* Classify ontology if needed */
        double classificationTime = 0;
       
        if ( !(reasoner.isClassified()) ){
          logger.info("Classifying KB...");
          Timer timerClassify = timers.startTimer( "classification" );
          reasoner.classify();
          timerClassify.stop();
          classificationTime = timerClassify.getTotal();
        }
       
        /* Load Abox into reasoner */
        reasoner.loadOntologies(Collections.singleton(abox));
         
        /* In each run this variable maps classes to number of instances (direct and indirect) retrieved for that class */
        HashMap<OWLClass, Integer> instancesPerClass = new HashMap<OWLClass, Integer>();
        /* Maps classes to number of direct instances */
        HashMap<OWLClass, Integer> directIndividualsCounts = new HashMap<OWLClass, Integer>();
        /* Maps classes to number of indirect instances */
        HashMap<OWLClass, Integer> indirectIndividualsCounts = new HashMap<OWLClass, Integer>();
       
        /* Total number of direct instances retrieved (among all classes) in the current run */
        int cumulativeDirectInstancesCnt = 0;
       
        /* Total number of indirect instances retrieved (among all classes) in the current run */
        int cumulativeIndirectInstancesCnt = 0;
         
        logger.info("Iterating over "+concepts.size()+" atomic concept names (calculated from original tbox)");
        /* Retrieve Instances from (T', A) */
        for (OWLClass cc : concepts){
          /* In each run this variable contains the instances (direct and indirect) retrieved from a given class */
          Set<OWLIndividual> individuals = new HashSet<OWLIndividual>()
           
          /* In each run this variable contains the instances (direct) retrieved from a given class */
          Set<OWLIndividual> directIndividuals = new HashSet<OWLIndividual>();
           
          /* get all individuals (direct and indirect) of class cc only if the class is defined in the ontology */
          if (reasoner.isDefined(cc)){
            timers.createTimer("retrieval");
            Timer timerRetrieval = timers.startTimer( "retrieval" );
            individuals = reasoner.getIndividuals(cc, false);
            timerRetrieval.stop();
           
            /* get direct individuals only */
            directIndividuals = reasoner.getIndividuals(cc, true);
           
            /* update instance retrieval time */
            instanceRetrievalTime += timerRetrieval.getTotal();
           
            if (individuals.size() > 0){
              logger.info("");
              logger.info("Instance relations found for class "+cc.getURI()+": "+individuals.size()+" (class's retrieval time:"+timerRetrieval.getTotal()+")");
              for (OWLIndividual owli : individuals){
                logger.info(individualCounter+": "+owli.getURI());
                individualCounter++;
              }         
            }
           
          }else{
            //System.out.println("Undefined Concept in Tbox: "+cc);
            logger.info("Undefined Concept in Tbox: "+cc);
          }
           
          /* save the instance relations that were retrieved for the class */
          classInstances.put(cc, individuals);
         
          /* Update number of instances (including direct and indirect) of the current class */
          instancesPerClass.put(cc, new Integer(individuals.size()));
                 
          /* save number of direct and indirect instances of each class */
          directIndividualsCounts.put(cc, new Integer(directIndividuals.size()));
          indirectIndividualsCounts.put(cc, new Integer(individuals.size()-directIndividuals.size()));
         
          if (isInterruptible){
            List<OWLOntologyChange> changesToMake = new Vector<OWLOntologyChange>();
            /* Add instances retrieved in the current run to the current Abox */
            OWLDataFactory factory = manager.getOWLDataFactory();
            timers.createTimer("aboxupdate");
            Timer timerAboxUpdate = timers.startTimer("aboxupdate");
            for (OWLIndividual ci : individuals){
              changesToMake.add(new AddAxiom(abox, factory.getOWLClassAssertionAxiom(ci, cc)));
            }
            List<OWLOntologyChange> actualChangesMade = manager.applyChanges(changesToMake);
            timerAboxUpdate.stop();
            newIndividualsToAdd += actualChangesMade.size();
            aboxUpdateTime = timerAboxUpdate.getTotal();
          }
           
          /* Update total number of direct and indirect instances retrieved in the current run */
          cumulativeDirectInstancesCnt += directIndividuals.size();
          cumulativeIndirectInstancesCnt += (individuals.size()-directIndividuals.size());
View Full Code Here

  public ApproximationResult getNextTBox(){
    org.mindswap.pellet.utils.Timers timers  = new Timers();
    timers.createTimer("selection");
   
    /* Selection contains concept names only */ 
    Timer timerSelection = timers.startTimer("selection");
    this.selection = this.strategy.getNextSelection();
    timerSelection.stop();
    long selectionTime = timerSelection.getTotal();
   
    if (this.selection == null){
      return null;
    }else {
      //if (this.selection.size() == this.strategy.sizeCompleteVocabulary()){
        /* the approximation is equal to the original tbox */
        //ApproximationResult approximationResult = new ApproximationResult(this.fullTBox, true);
        //approximationResult.setOntologyPhysicalURI(this.fullTboxURI);
        //approximationResult.setSelectionTime(selectionTime);
        //return approximationResult;
      //}
    //}
   
    try {
      logger.info("Computing Approximated Tbox...");
      timers.createTimer("rewrite");
     
      OWLOntologyManager manager = null;
      manager = OWLManager.createOWLOntologyManager();
      OWLDataFactory factory = manager.getOWLDataFactory();
     
      /* create the logical and physical URI of the new Tbox */
      //String tmpURI = createTboxURI(this.tmpOntologyURI);
      URI newTboxLogicalURI = URI.create(createTboxURI(this.tmpOntologyURI));
      //URI newTboxPhysicalURI = URI.create(tmpURI);
     
      /* Create the temporal TBox that will contain the selection made out of the original (full) TBox */
      OWLOntology approximatedTbox = manager.createOntology(newTboxLogicalURI);
     
      /* Get all the axioms of the original Tbox */
      Set<OWLLogicalAxiom> axioms = this.fullTBox.getLogicalAxioms();
     
      /* Iterate over all logical axioms and rewrite them if necessary. Add each (possibly rewritten) axiom to
       * the approximated Tbix */
      //long axiomRewritingTimeStart = System.nanoTime();
      Timer timerRewrite = timers.startTimer("rewrite");
      for (OWLLogicalAxiom ca : axioms){
        //logger.info("Axiom: "+ca.toString());
        if (!(ca instanceof OWLClassAssertionAxiom) && !(ca instanceof OWLIndividualAxiom)){
          if (ca instanceof OWLSubClassAxiom){
            //logger.info("");
            //logger.info("SubClass Axiom: "+ca.toString());
            OWLSubClassAxiom cur = (OWLSubClassAxiomImpl)ca;
            OWLDescription subClass = cur.getSubClass();
            OWLDescription superClass = cur.getSuperClass();
            OWLDescription subClassMinus = getRewriteMinus(subClass, factory);
            OWLDescription superClassPlus = getRewritePlus(superClass, factory);
            OWLSubClassAxiom subClassAxiom = factory.getOWLSubClassAxiom(subClassMinus, superClassPlus);
            //logger.info("Approximated axiom: "+subClassAxiom);
            manager.applyChange(new AddAxiom(approximatedTbox, subClassAxiom));
          }else if (ca instanceof OWLEquivalentClassesAxiom){
            //logger.info("");
            //logger.info("EquivalentClass Axiom: "+ca.toString());
            OWLEquivalentClassesAxiom equivalentClassAxiom = (OWLEquivalentClassesAxiom)ca;
            //System.out.println("[OWLEquivalentClassesAxiom] "+equivalentClassAxiom.toString());
            Set<OWLSubClassAxiom> subClassAxioms = equivalentClassAxiom.asSubClassAxioms();
            for (OWLSubClassAxiom sca : subClassAxioms){
              OWLDescription subClass = sca.getSubClass();
              OWLDescription superClass = sca.getSuperClass();
              OWLDescription subClassMinus = getRewriteMinus(subClass, factory);
              OWLDescription superClassPlus = getRewritePlus(superClass, factory);
              OWLSubClassAxiom subClassAxiom = factory.getOWLSubClassAxiom(subClassMinus, superClassPlus);
              //logger.info("Approximated axiom: "+subClassAxiom);
              manager.applyChange(new AddAxiom(approximatedTbox, subClassAxiom));               
            }
          }else if (ca instanceof OWLDisjointClassesAxiom){
            //logger.info("");
            //logger.info("DisjointClass Axiom: "+ca.toString());
            OWLDisjointClassesAxiom disjointAxiom = (OWLDisjointClassesAxiom)ca;
            Set<OWLDescription> descriptions = disjointAxiom.getDescriptions();
            /* Cretae intersection of all disjoint classes */
            OWLObjectIntersectionOf intersection = factory.getOWLObjectIntersectionOf(descriptions);             
            OWLDescription subClassMinus = getRewriteMinus(intersection, factory);
            OWLDescription superClassPlus = getRewritePlus(factory.getOWLNothing(), factory);
            OWLSubClassAxiom subClassAxiom = factory.getOWLSubClassAxiom(subClassMinus, superClassPlus);
            //logger.info("Approximated axiom: "+subClassAxiom);
            manager.applyChange(new AddAxiom(approximatedTbox, subClassAxiom));
          }else if (ca instanceof OWLObjectPropertyDomainAxiom){
            OWLObjectPropertyDomainAxiom domainAxiom = (OWLObjectPropertyDomainAxiom)ca;
            OWLDescription domainPlus = getRewritePlus(domainAxiom.getDomain(), factory);
            OWLObjectPropertyDomainAxiom approximatedDomainAxiom = factory.getOWLObjectPropertyDomainAxiom(domainAxiom.getProperty(), domainPlus);
            manager.applyChange(new AddAxiom(approximatedTbox, approximatedDomainAxiom));
          }else if (ca instanceof OWLObjectPropertyRangeAxiom){
            OWLObjectPropertyRangeAxiom rangeAxiom = (OWLObjectPropertyRangeAxiom)ca;
            OWLDescription rangePlus = getRewritePlus(rangeAxiom.getRange(), factory);
            OWLObjectPropertyRangeAxiom approximatedRangeAxiom = factory.getOWLObjectPropertyRangeAxiom(rangeAxiom.getProperty(), rangePlus);
            manager.applyChange(new AddAxiom(approximatedTbox, approximatedRangeAxiom));
          }else{
            manager.applyChange(new AddAxiom(approximatedTbox, ca));   
            logger.info("[UNMODIFIED AXIOM] [type="+ca.getAxiomType().getName()+"]: "+ca.toString());
          }
        }else{
          manager.applyChange(new AddAxiom(approximatedTbox, ca));
          logger.info("[UNMODIFIED AXIOM] [type="+ca.getAxiomType().getName()+"]: "+ca.toString());
        }
      }
      timerRewrite.stop();
      long axiomRewritingTime = timerRewrite.getTotal();
     
      /*
      it = axioms.iterator();
      List<OWLAxiomChange> toRemove = new Vector<OWLAxiomChange>();
      while (it.hasNext()){
View Full Code Here

      // reasoner.loadOntologies(Collections.singleton(abox));
      /* Classify the ontology if necessary */
      if (!reasoner.isClassified())
      {
        /* Measure time using Benchmarking framework */
        Timer timerClassify = timers.startTimer("classification");
        reasoner.classify();
        timerClassify.stop();
        classificationTime = timerClassify.getTotal();
      }

      /* Load Abox into reasoner */
      reasoner.loadOntologies(Collections.singleton(abox));
      if (!reasoner.isClassified())
      {
        reasoner.classify();
      }

      /*
       * Maps each class to the number of instances (including direct and
       * indirect)
       */
      HashMap<OWLClass, Integer> allIndividualsCounts = new HashMap<OWLClass, Integer>();

      /* Maps each class to the number of direct instances */
      HashMap<OWLClass, Integer> directIndividualsCounts = new HashMap<OWLClass, Integer>();

      /* Maps each class to the number of indirect instances */
      HashMap<OWLClass, Integer> indirectIndividualsCounts = new HashMap<OWLClass, Integer>();

      int individualCounter = 1;

      for (OWLClass cc : classes)
      {
        allIndividuals = new HashSet<OWLIndividual>();
        directIndividuals = new HashSet<OWLIndividual>();

        if (reasoner.isDefined(cc))
        {
          /*
           * retrieve all individuals of the class (direct and
           * indirect individuals)
           */
          timers.createTimer("retrieval");
          Timer timerRetrieval = timers.startTimer("retrieval");
          allIndividuals = reasoner.getIndividuals(cc, false);
          timerRetrieval.stop();

          /* update instance retrieval time */
          instanceRetrievalTime += timerRetrieval.getTotal();

          /* retrieve all direct instances of the class */
          directIndividuals = reasoner.getIndividuals(cc, true);
        } else
        {
View Full Code Here

      double aboxUpdateTime = 0;
      double time = 0;

      // System.out.println("--->approximating...");
      timers.createTimer("approximation");
      Timer timerApproximation = timers.startTimer("approximation");
      approximationResult = approximation.getNextTBox();
      timerApproximation.stop();
      if (measureApproximationTime)
      {
        approximationTime += timerApproximation.getTotal();
      }

      if (approximationResult != null)
      {
        approximatedTboxOntology = approximationResult
            .approximatedOntology();

        URI tboxPhysicalURI = createURI(tmpTboxPhysicalURI, runCounter);
        if (saveApproximatedTbox)
        {
          saveOntology(approximatedTboxOntology, tboxPhysicalURI);
        }

        // System.out.println("--->classifying...");
        reasoner = reasonerFactory.createReasoner(manager);
        reasoner.loadOntologies(Collections
            .singleton(approximatedTboxOntology));
        timers.createTimer("classification");
        if (!(reasoner.isClassified()))
        {
          Timer timerClassify = timers.startTimer("classification");
          reasoner.classify();
          timerClassify.stop();
          classificationTime += timerClassify.getTotal();
        }

        if (approximationResult.isOriginal())
        {
          aboxPhysicalURI = originalAboxPhysicalURI;
        }

        aboxOntology = manager
            .loadOntologyFromPhysicalURI(aboxPhysicalURI);

        reasoner.loadOntologies(Collections.singleton(aboxOntology));

        // System.out.println("--->retrieving instances...");
        for (OWLClass cc : concepts)
        {
          Set<OWLIndividual> individuals = new HashSet<OWLIndividual>();
          Set<OWLIndividual> directIndividuals = new HashSet<OWLIndividual>();

          if (reasoner.isDefined(cc))
          {
            timers.createTimer("retrieval");
            Timer timerRetrieval = timers.startTimer("retrieval");
            individuals = reasoner.getIndividuals(cc, false);
            timerRetrieval.stop();
            instanceRetrievalTime += timerRetrieval.getTotal();
          }

          directIndividuals = reasoner.getIndividuals(cc, true);
          allIndividualsCounts.put(cc,
              new Integer(individuals.size()));
          directIndividualsCounts.put(cc, new Integer(
              directIndividuals.size()));
          indirectIndividualsCounts.put(cc, new Integer(individuals
              .size()
              - directIndividuals.size()));

          if (isInterruptible)
          {

            List<OWLOntologyChange> changesToMake = new Vector<OWLOntologyChange>();
            OWLDataFactory factory = manager.getOWLDataFactory();
            timers.createTimer("aboxupdate");
            Timer timerAboxUpdate = timers.startTimer("aboxupdate");
            for (OWLIndividual ci : individuals)
            {
              changesToMake.add(new AddAxiom(aboxOntology,
                  factory.getOWLClassAssertionAxiom(ci, cc)));
            }
            timerAboxUpdate.stop();
            aboxUpdateTime += timerAboxUpdate.getTotal();
          }

          cumulativeDirectIndividualsCounts += directIndividuals
              .size();
          cumulativeIndirectIndividualsCounts += (individuals.size() - directIndividuals
View Full Code Here

    reasoner.loadOntologies(Collections.singleton(aboxOntology));
    timers.createTimer("classification");

    if (!reasoner.isClassified())
    {
      Timer timerClassify = timers.startTimer("classification");
      reasoner.classify();
      timerClassify.stop();
      classificationTime += timerClassify.getTotal();
    }
    // System.out.println("--->retrieving instances...");
    for (OWLClass cc : classes)
    {
      allIndividuals = new HashSet<OWLIndividual>();
      directIndividuals = new HashSet<OWLIndividual>();
      timers.createTimer("retrieval");
      Timer timerRetrieval = timers.startTimer("retrieval");
      allIndividuals = reasoner.getIndividuals(cc, false);
      timerRetrieval.stop();
      instanceRetrievalTime += timerRetrieval.getTotal();

      fullCassIndividuals.put(cc, allIndividuals);

      directIndividuals = reasoner.getIndividuals(cc, true);
View Full Code Here

    // We need some timing to show the performance of the classification
    Timers timers = new Timers();

    // We classify the ontology and use a specific timer to keep track of
    // the time required for the classification
    Timer t = timers.createTimer( "First classification" );
    t.start();
    classifier.classify();
    t.stop();
       
    System.out.println( "\nClassification time: " + t.getTotal() + "ms");
    System.out.println( "Subclasses of " + pain + ": " + classifier.getSubClasses( pain, true ).getFlattened() + "\n");
   
    // Now create a new OWL axiom, subClassOf(Headache, Pain)
    OWLAxiom axiom = OWL.subClassOf( headache, pain );

    // Add the axiom to the ontology, which creates a change event
    OWL.manager.applyChange( new AddAxiom( ontologyTBox, axiom ) );

    // Now we create a second timer to keep track of the performance of the
    // second classification
    t = timers.createTimer("Second classification");
    t.start();
    classifier.classify();
    t.stop();
   
    System.out.println( "\nClassification time: " + t.getTotal() + "ms");
    System.out.println( "Subclasses of " + pain + ": " + classifier.getSubClasses( pain, true ).getFlattened() + "\n");

    // Remove the axiom from the ontology, which creates a change event
    OWL.manager.applyChange( new RemoveAxiom( ontologyTBox, axiom ) );

    // Now we create a third timer to keep track of the performance of the
    // third classification
    timers.startTimer( "Third classification" );
    classifier.classify();
    timers.stopTimer( "Third classification" );
   
    System.out.println( "\nClassification time: " + t.getTotal() + "ms");
    System.out.println( "Subclasses of " + pain + ": " + classifier.getSubClasses( pain, true ).getFlattened() + "\n");
   
    // Finally, print the timing. As you can see, the second classification
    // takes significantly less time, which is the characteristic of the
    // incremental classifier.
View Full Code Here

  /**
   * {@inheritDoc}
   */
  public void load(Iterable<Graph> graphs) throws UnsupportedFeatureException {
    Timer timer = kb.timers.startTimer( "load" );

    monitor.setProgressTitle( "Loading" );
    monitor.taskStarted();
   
    graph = EMPTY_GRAPH;
    preprocess();

    for (Graph g : graphs) {
      graph = g;
      processTypes();   
        }

    for (Graph g : graphs) {
      graph = g;
      processTriples()
        }
   
    processUntypedResources();

    monitor.taskFinished();

    timer.stop();
  }
View Full Code Here

  public void setMaxIteration(int maxIteration) {
    this.maxIteration = maxIteration;
  }

  public void profile(String[] dataset, String queryset) throws Exception {
    Timer t = null;

    String dataName = dataset[0];

    Map<String, Query> queries = readQueries( queryset );

    KnowledgeBase kb = loadData( dataset );

    double parseTime = timers.getTimerTotal( "parse" ) / 1000.0;
    double consTime = timers.getTimerTotal( "consistency" ) / 1000.0;
   
    double classifyTime = 0;
    double realizeTime = 0;
    double sizeEstimateTime = 0;
   
    if( isSizeEstimateAll() ) {
      t = timers.startTimer( "sizeEstimateAll" );
      kb.getSizeEstimate().computeAll();
      t.stop();
     
    }

    System.out.println( "Parsing/Loading  : " + parseTime );
    System.out.println( "Consistency      : " + consTime );
   
    if( isClassify() ) {
      classifyTime = timers.getTimerTotal( "classify" ) / 1000.0;
      System.out.println( "Classify         : " + classifyTime );
    }
   
    if( isRealize() ) {
      realizeTime = timers.getTimerTotal( "realize" ) / 1000.0;   
      System.out.println( "Realize         : " + realizeTime );
    }
   
    if( isSizeEstimateAll() ) {
      sizeEstimateTime = timers.getTimerTotal( "sizeEstimateAll" ) / 1000.0;
      System.out.println( "Size Estimate   : " + sizeEstimateTime );
    }
   
    double totalSetupTime = consTime + sizeEstimateTime + classifyTime + realizeTime;
    System.out.println( "Total Setup      : " + totalSetupTime );

    for( int i = 0; i < maxIteration; i++ ) {
      System.out.println( "\n\n\nITERATION: " + (i + 1) + "\n\n\n" );

      Collection<Result<String>> currResult = new ArrayList<Result<String>>();

      currResult.add( new Result<String>( "consistency", consTime ) );
      if( isClassify() )
        currResult.add( new Result<String>( "classify", classifyTime ) );
      if( isRealize() )
        currResult.add( new Result<String>( "realize", realizeTime ) );
      if( isSizeEstimateAll() )
        currResult.add( new Result<String>( "estimate", sizeEstimateTime ) );
      // currResult.add( new Result<String>( "setup", totalSetupTime ) );

      for( Map.Entry<String, Query> entry : queries.entrySet() ) {
        String queryName = entry.getKey();
        Query query = entry.getValue();

        if( queries.size() > 1 )
          System.out.println( "Query: " + queryName );

        if( printQuery )
          System.out.println( query );

        t = timers.startTimer( "query" );

        QueryExecution queryExec = SparqlDLExecutionFactory.create( query, model );

        ResultSet queryResults = queryExec.execSelect();

        // we need to consume the results to completely answer the query
        ResultSetMem resultMem = new ResultSetMem( queryResults );

        int count = resultMem.size();

        t.stop();

        double queryTime = t.getLast() / 1000.0;

        if( printQueryResults )
          ResultSetFormatter.out( resultMem, model );

        System.out.println( "Query time: " + queryTime );
View Full Code Here

      kb.timers.print();
    }
  }

  public KnowledgeBase loadData(String[] dataset) throws Exception {
    Timer t = timers.startTimer( "parse" );

    loader.parse( dataset );
    model = loader.getModel();

    System.out.println();
    System.out.println( "Triples        : " + model.getBaseModel().size() );
       
    t.stop();

    KnowledgeBase kb = loader.getKB();

    t = timers.startTimer( "load" );
    model.prepare();
    t.stop();
   
    ProfileUtils.printCounts( kb );

    t = timers.startTimer( "consistency" );
    kb.isConsistent();
    t.stop();
   
    ProfileUtils.printCounts( kb.getABox() );

    if( classify ) {
      t = timers.startTimer( "classify" );

      kb.classify();

      t.stop();
    }

    if( realize ) {
      t = timers.startTimer( "realize" );

      kb.realize();

      t.stop();
    }

    return kb;
  }
View Full Code Here

TOP

Related Classes of org.mindswap.pellet.utils.Timer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.