/** * @see #getCurrentlyBestEvaluatedDescriptions(int) * @param nrOfDescriptions Limit for the number or returned descriptions. * @return The best class descriptions found by the learning algorithm so far. */ @Override public synchronized List<OWLClassExpression> getCurrentlyBestDescriptions(int nrOfDescriptions) { return getCurrentlyBestDescriptions(nrOfDescriptions, false); }
@Override public void run() { logger.debug("Computing linear combination..."); long start = System.currentTimeMillis(); List<OWLClassExpression> descriptions = la.getCurrentlyBestDescriptions(5); classifier.getLinearCombination(descriptions); long end = System.currentTimeMillis(); if (logger.isDebugEnabled()) { logger.debug("Operation took " + (end - start) + "ms"); } } }
/** * @see #getCurrentlyBestEvaluatedDescriptions(int,double,boolean) * @param nrOfDescriptions Limit for the number or returned descriptions. * @param filterNonMinimalDescriptions Remove non-minimal descriptions (e.g. those which can be shortened * to an equivalent concept) from the returned set. * @return The best class descriptions found by the learning algorithm so far. */ public synchronized List<OWLClassExpression> getCurrentlyBestDescriptions(int nrOfDescriptions, boolean filterNonMinimalDescriptions) { List<OWLClassExpression> currentlyBest = getCurrentlyBestDescriptions(); List<OWLClassExpression> returnList = new LinkedList<>(); for(OWLClassExpression ed : currentlyBest) { if(returnList.size() >= nrOfDescriptions) { return returnList; } if(!filterNonMinimalDescriptions || ConceptTransformation.isDescriptionMinimal(ed)) { returnList.add(ed); } } return returnList; }
@WebMethod public int[] getConceptDepth(int id, int nrOfConcepts) throws ClientNotKnownException { ClientState state = getState(id); List<OWLClassExpression> bestConcepts = state.getLearningAlgorithm().getCurrentlyBestDescriptions(nrOfConcepts); Iterator<OWLClassExpression> iter = bestConcepts.iterator(); int[] depth = new int[bestConcepts.size()]; int i = 0; while (iter.hasNext()) { depth[i] = OWLClassExpressionUtils.getDepth(iter.next()); i++; } return depth; }
@WebMethod public int[] getConceptArity(int id, int nrOfConcepts) throws ClientNotKnownException { ClientState state = getState(id); List<OWLClassExpression> bestConcepts = state.getLearningAlgorithm().getCurrentlyBestDescriptions(nrOfConcepts); Iterator<OWLClassExpression> iter = bestConcepts.iterator(); int[] arity = new int[bestConcepts.size()]; int i = 0; while (iter.hasNext()) { arity[i] = OWLClassExpressionUtils.getArity(iter.next()); i++; } return arity; }
/** * * @param id The session ID. * @param nrOfConcepts * @param format * @return * @throws ClientNotKnownException Thrown if client (session ID) is not known. */ @WebMethod public String[] getCurrentlyBestConcepts(int id, int nrOfConcepts, String format) throws ClientNotKnownException { ClientState state = getState(id); List<OWLClassExpression> bestConcepts = state.getLearningAlgorithm().getCurrentlyBestDescriptions(nrOfConcepts); List<String> conc= new LinkedList<>(); Iterator<OWLClassExpression> iter=bestConcepts.iterator(); while (iter.hasNext()) switch (format) { case "manchester": conc.add(OWLAPIRenderers.toManchesterOWLSyntax(iter.next())); break; case "kb": conc.add(OWLAPIRenderers.toManchesterOWLSyntax(iter.next())); break; default: conc.add(iter.next().toString()); break; } return conc.toArray(new String[conc.size()]); }