public static Map<String, SortedSet<String>> getStringMap( Map<OWLIndividual, SortedSet<OWLIndividual>> roleMembers) { Map<String, SortedSet<String>> ret = new TreeMap<>(); for (OWLIndividual i : roleMembers.keySet()) { ret.put(i.toStringID(), getStringSet(roleMembers.get(i))); } return ret; }
public static String prettyPrintNanoSeconds(long nanoSeconds, boolean printMicros, boolean printNanos) { // String str = ""; // long seconds = 0; // long milliSeconds = 0; // long microseconds = 0; long seconds = nanoSeconds / 1000000000; nanoSeconds = nanoSeconds % 1000000000; long milliSeconds = nanoSeconds / 1000000; nanoSeconds = nanoSeconds % 1000000; // Mikrosekunden werden immer angezeigt, Sekunden nur falls größer 0 String str = ""; if (seconds > 0) str = seconds + "s "; str += milliSeconds + "ms"; if (printMicros) { long microSeconds = nanoSeconds / 1000; nanoSeconds = nanoSeconds % 1000; str += " " + microSeconds + "usec"; } if (printNanos) { str += " " + nanoSeconds + "ns"; } return str; }
if(allowedConcepts != null) { Helper.checkConcepts(reasoner, allowedConcepts); usedConcepts = allowedConcepts; } else if(ignoredConcepts != null) { usedConcepts = Helper.computeConceptsUsingIgnoreList(reasoner, ignoredConcepts); } else { usedConcepts = Helper.computeConcepts(reasoner);
/** * Computes an internal object property hierarchy that only contains * object properties that are allowed. * @return optimized object property hierarchy */ protected ObjectPropertyHierarchy initObjectPropertyHierarchy() { Set<OWLObjectProperty> usedProperties; if(allowedObjectProperties != null) { // sanity check to control if no non-existing object properties are in the list Helper.checkRoles(reasoner, allowedObjectProperties); usedProperties = allowedObjectProperties; } else if(ignoredObjectProperties != null) { usedProperties = Helper.computeEntitiesUsingIgnoreList(reasoner, EntityType.OBJECT_PROPERTY, ignoredObjectProperties); } else { usedProperties = Helper.computeEntities(reasoner, EntityType.OBJECT_PROPERTY); } ObjectPropertyHierarchy hierarchy = (ObjectPropertyHierarchy) reasoner.getObjectPropertyHierarchy().cloneAndRestrict(usedProperties); // hierarchy.thinOutSubsumptionHierarchy(); return hierarchy; }
/** * Computes an internal data property hierarchy that only contains * data properties that are allowed. * @return optimized data property hierarchy */ protected DatatypePropertyHierarchy initDataPropertyHierarchy() { Set<OWLDataProperty> usedProperties; if(allowedDataProperties != null) { // sanity check to control if no non-existing data properties are in the list Helper.checkEntities(reasoner, allowedDataProperties); usedProperties = allowedDataProperties; } else if(ignoredDataProperties != null) { usedProperties = Helper.computeEntitiesUsingIgnoreList(reasoner, EntityType.DATA_PROPERTY, ignoredDataProperties); } else { usedProperties = Helper.computeEntities(reasoner, EntityType.DATA_PROPERTY); } DatatypePropertyHierarchy hierarchy = (DatatypePropertyHierarchy) reasoner.getDatatypePropertyHierarchy().cloneAndRestrict(usedProperties); // hierarchy.thinOutSubsumptionHierarchy(); return hierarchy; }
@Override public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { if (bean instanceof Component) { Component c = (Component) bean; String componentName = AnnComponentManager.getName(c); try { logger.info("Initializing component '{}' of type {} ...", beanName, componentName); long startTime = System.currentTimeMillis(); c.init(); long stopTime = System.currentTimeMillis(); long elapsedTime = stopTime - startTime; logger.info("... initialized component '{}' in {}. Status: OK", new String[]{beanName, Helper.prettyPrintMilliSeconds(elapsedTime)}); } catch (ComponentInitException e) { throw new RuntimeException("Problem initializing the component \"" + componentName + "\" with beanName: " + beanName, e); } catch (Exception e) { /** Catch any exception as an init exception */ logger.warn("Could not initialize component \"" + componentName + "\""); throw new RuntimeException(e); } } return bean; }
ignoredConcepts.add(new OWLClassImpl(IRI.create("http://www.test.de/test#ZERO"))); ignoredConcepts.add(new OWLClassImpl(IRI.create("http://www.test.de/test#ONE"))); Set<OWLClass> usedConcepts = Helper.computeConceptsUsingIgnoreList(reasoner, ignoredConcepts);
/** * Checks whether the entities exist in background knowledge * @param entities The entities to check. * @return The first non-existing entity or null if they are all in the * background knowledge. */ public static <T extends OWLEntity> T checkEntities(AbstractReasonerComponent rs, Set<T> entities) { Set<T> existingEntities = (Set<T>) computeEntities(rs, entities.iterator().next().getEntityType()); for (T entity : entities) { if(!existingEntities.contains(entity)) return entity; } return null; }
@Override public void start() { nanoStartTime = System.nanoTime(); while(!stop && !stoppingCriteriaSatisfied()) { // compute next partial solution EvaluatedDescription<? extends Score> partialSolution = computePartialSolution(); // add to global solution if criteria are satisfied if(addPartialSolution(partialSolution)) { log.info("new partial solution found: {}", partialSolution); // update the learning problem updateLearningProblem(partialSolution); } } log.info("finished computation in {}.\n top 10 solutions:\n{}", Helper.prettyPrintMilliSeconds(getCurrentRuntimeInMilliSeconds()), getSolutionString()); }
str += "number of retrievals: " + nrOfRetrievals + "\n"; str += "retrieval reasoning time: " + Helper.prettyPrintNanoSeconds(retrievalReasoningTimeNs) + " ( " + Helper.prettyPrintNanoSeconds(getTimePerRetrievalNs()) + " per retrieval)" + "\n"; + nrOfMultiInstanceChecks + " multiple)\n"; str += "instance check reasoning time: " + Helper.prettyPrintNanoSeconds(instanceCheckReasoningTimeNs) + " ( " + Helper.prettyPrintNanoSeconds(getTimePerInstanceCheckNs()) + " per instance check)\n"; + " (" + nrOfMultiSubsumptionChecks + " multiple)\n"; str += "subsumption reasoning time: " + Helper.prettyPrintNanoSeconds(subsumptionReasoningTimeNs) + " ( " + Helper.prettyPrintNanoSeconds(getTimePerSubsumptionCheckNs()) + " per subsumption check)\n"; + Helper.prettyPrintNanoSeconds(overallReasoningTimeNs) + "\n"; return str;
public static SortedSetTuple<String> getStringTuple(SortedSetTuple<OWLIndividual> tuple) { return new SortedSetTuple<>(getStringSet(tuple.getPosSet()), getStringSet(tuple .getNegSet())); }
private void printAlgorithmRunStats() { if (stop) { logger.info("Algorithm stopped ("+expressionTests+" descriptions tested). " + searchTree.size() + " nodes in the search tree.\n"); } else { totalRuntimeNs = System.nanoTime()-nanoStartTime; logger.info("Algorithm terminated successfully (time: " + Helper.prettyPrintNanoSeconds(totalRuntimeNs) + ", "+expressionTests+" descriptions tested, " + searchTree.size() + " nodes in the search tree).\n"); logger.info(reasoner.toString()); } }
private void validate(AbstractCELA la, AbstractClassExpressionLearningProblem lp, AbstractReasonerComponent rs, int currFold, Set<OWLIndividual> trainPos, Set<OWLIndividual> trainNeg, Set<OWLIndividual> testPos, Set<OWLIndividual> testNeg){ Set<String> pos = Helper.getStringSet(trainPos); Set<String> neg = Helper.getStringSet(trainNeg); String output = ""; output += "+" + new TreeSet<>(pos) + "\n";
private void printAlgorithmRunStats() { if (stop) { logger.info("Algorithm stopped ("+expressionTests+" descriptions tested). " + searchTree.size() + " nodes in the search tree.\n"); } else { totalRuntimeNs = System.nanoTime()-nanoStartTime; logger.info("Algorithm terminated successfully (time: " + Helper.prettyPrintNanoSeconds(totalRuntimeNs) + ", "+expressionTests+" descriptions tested, " + searchTree.size() + " nodes in the search tree).\n"); logger.info(reasoner.toString()); } }
Set<String> pos = Helper.getStringSet(trainingSetsPos.get(currFold)); Set<String> neg = Helper.getStringSet(trainingSetsNeg.get(currFold)); if(lp instanceof PosNegLP){ ((PosNegLP)lp).setPositiveExamples(trainingSetsPos.get(currFold));
public static String convMonitorToString (Monitor m) { String retVal = m.getLabel()+"|\t"; String unit = m.getUnits(); retVal+=unit+"|\t"; long content = new Double(m.getTotal()).longValue(); content = content / (1000*1000); String contentstr = (unit.equals(MS))? Helper.prettyPrintNanoSeconds(content ) : m.getHits()+"" ; retVal+= "total:"+contentstr+"|\t"; long avg = new Double(m.getAvg()).longValue(); avg = avg / (1000*1000); String avgstr = (unit.equals(MS))? Helper.prettyPrintNanoSeconds(avg ) : avg+"" ; retVal+= "avg:"+avgstr+"|\t"; return retVal; }
return Collections.emptyList(); SortedSet<String> posExStr = Helper.getStringSet(posExamples); System.out.println("done (" + posExStr.size()+ " examples found in " + runTime + " ms)");
public static void main(String[] args) throws ClassNotFoundException, SQLException, NoSuchAlgorithmException, UnsupportedEncodingException { SparqlEndpoint endpoint = SparqlEndpoint.getEndpointDBpediaLiveAKSW(); String resource = "http://dbpedia.org/resource/Leipzig"; String query = "CONSTRUCT { <"+resource+"> ?p ?o } WHERE { <"+resource+"> ?p ?o }"; System.out.println("query: " + query); ExtractionDBCache h2 = new ExtractionDBCache("cache"); long startTime = System.nanoTime(); Model m = h2.executeConstructQuery(endpoint, query); // for(int i=0; i<1000; i++) { // h2.executeConstructQuery(endpoint, query); // } long runTime = System.nanoTime() - startTime; System.out.println("Answer obtained in " + Helper.prettyPrintNanoSeconds(runTime)); System.out.println(ExtractionDBCache.toNTriple(m)); }
private void validate(AbstractCELA la, AbstractClassExpressionLearningProblem lp, AbstractReasonerComponent rs, int currFold, Set<OWLIndividual> trainPos, Set<OWLIndividual> trainNeg,Set<OWLIndividual> trainUnd, Set<OWLIndividual> testPos, Set<OWLIndividual> testNeg, Set<OWLIndividual> testUnd){ Set<String> pos = Helper.getStringSet(trainPos); Set<String> neg = Helper.getStringSet(trainNeg); Set<String> und = Helper.getStringSet(trainUnd); String output = ""; TreeSet<String> treeSetPos = new TreeSet<>(pos);
+ searchTree.best().getShortDescription(); logger.debug(expandedNodeString); logger.debug("algorithm runtime " + Helper.prettyPrintNanoSeconds(algorithmRuntime)); logger.debug("size of candidate set: " + searchTree.size()); logger.debug("subsumption time: " + Helper.prettyPrintNanoSeconds(reasoner.getSubsumptionReasoningTimeNs())); logger.debug("instance check time: " + Helper.prettyPrintNanoSeconds(reasoner.getInstanceCheckReasoningTimeNs())); logger.debug("retrieval time: " + Helper.prettyPrintNanoSeconds(reasoner.getRetrievalReasoningTimeNs()));