public void setReasoners(AbstractReasonerComponent... rcs) throws ComponentInitException { this.rcs = rcs; for(AbstractReasonerComponent rc : this.rcs) { rc.init(); } } }
/** * Initialise all components. * @param id Session ID. * @throws ComponentInitException Thrown if an error occurs during component initialisation. */ @WebMethod public void initAll(int id) throws ClientNotKnownException, ComponentInitException { ClientState state = getState(id); logger.info("Initializing knowledge sources..."); for(AbstractKnowledgeSource ks : state.getKnowledgeSources()) ks.init(); logger.info("Initializing reasoner..."); state.getReasonerComponent().init(); logger.info("Initializing learning problem..."); state.getLearningProblem().init(); logger.info("Initializing learning algorithm..."); state.getLearningAlgorithm().init(); }
public static void main(String[] args) throws Exception{ // StringRenderer.setRenderer(Rendering.DL_SYNTAX); Logger.getRootLogger().setLevel(Level.INFO); Logger.getLogger(PCELOE.class).setLevel(Level.DEBUG); Logger.getLogger(PCELOE.class).addAppender(new FileAppender(new PatternLayout( "[%t] %c: %m%n" ), "log/parallel_run.txt", false)); AbstractKnowledgeSource ks = new OWLFile("../examples/family/father_oe.owl"); ks.init(); AbstractReasonerComponent rc = new ClosedWorldReasoner(ks); rc.init(); ClassLearningProblem lp = new ClassLearningProblem(rc); lp.setClassToDescribe(new OWLClassImpl(IRI.create("http://example.com/father#father"))); lp.setCheckConsistency(false); lp.init(); PCELOE alg = new PCELOE(lp, rc); alg.setMaxExecutionTimeInSeconds(10); alg.setNrOfThreads(4); // alg.setMaxClassDescriptionTests(200); alg.init(); alg.start(); }
public static void main(String[] args) throws Exception { KnowledgeSource ks = new OWLFile("../examples/swore/swore.rdf"); AbstractReasonerComponent rc = new ClosedWorldReasoner(ks); rc.init(); ClassLearningProblem lp = new ClassLearningProblem(rc); lp.setClassToDescribe(new OWLClassImpl(IRI.create("http://ns.softwiki.de/req/CustomerRequirement"))); lp.init(); CELOE celoe = new CELOE(lp, rc); celoe.setNoisePercentage(1.0); celoe.setMaxExecutionTimeInSeconds(3); celoe.init(); celoe.start(); List<OWLClassExpression> descriptions = new ArrayList<>(); for (EvaluatedDescription<? extends Score> ed : celoe.getCurrentlyBestEvaluatedDescriptions(100)) { if(((EvaluatedDescriptionClass)ed).getAdditionalInstances().size() > 0){ System.out.println(ed); System.out.println(((EvaluatedDescriptionClass)ed).getAdditionalInstances()); descriptions.add(ed.getDescription()); } if(descriptions.size() == 3) break; } // descriptions.addAll(celoe.getCurrentlyBestDescriptions(2)); // descriptions.add(new NamedClass("http://ns.softwiki.de/req/Requirement")); // descriptions.add(new NamedClass("http://ns.softwiki.de/req/Customer")); DescriptionLinearClassifier dlc = new DescriptionLinearClassifier(lp, rc); dlc.getLinearCombination(descriptions); }
private static void setup(String turtleString) throws Exception{ OWLOntology ontology = OWLManager.createOWLOntologyManager().loadOntologyFromOntologyDocument( new ByteArrayInputStream(turtleString.getBytes(StandardCharsets.UTF_8))); KnowledgeSource ks = new OWLAPIOntology(ontology); ks.init(); reasoner = new OWLAPIReasoner(ks); reasoner.init(); // get examples Set<OWLIndividual> posExamples = new HashSet<>(); Set<OWLIndividual> negExamples = new HashSet<>(); for (OWLIndividual ind : ontology.getIndividualsInSignature()) { if (ind.toStringID().startsWith("http://example.org/p")) { posExamples.add(ind); } else { negExamples.add(ind); } } // create learning problem lp = new PosNegLPStandard(reasoner); lp.setPositiveExamples(posExamples); lp.setNegativeExamples(negExamples); }
@Before public void setUp() throws Exception { reasoner = new OWLAPIReasoner(); reasoner.setSources(new OWLAPIOntology(OWLManager.createOWLOntologyManager().loadOntologyFromOntologyDocument( new File("src/test/resources/org/dllearner/utilities/property_hierarchy.ttl")))); reasoner.init(); df = new OWLDataFactoryImpl(); pm = new DefaultPrefixManager(); pm.setDefaultPrefix("http://www.dl-learner.org/test/hierarchy/properties#"); }
@Test public void test4() throws ComponentInitException, ParseException, IOException { Logger logger = Logger.getRootLogger(); logger.setLevel(Level.TRACE); SimpleLayout layout = new SimpleLayout(); FileAppender app = new FileAppender(layout, "log/el/log.txt", false); logger.removeAllAppenders(); logger.addAppender(app); String ont = "../test/galen2.owl"; KnowledgeSource source = new OWLFile(ont); source.init(); AbstractReasonerComponent reasoner = new OWLAPIReasoner(Collections.singleton(source)); reasoner.init(); System.out.println("Galen loaded."); // Description input = KBParser.parseConcept("(\"http://www.co-ode.org/ontologies/galen#15.0\" AND (\"http://www.co-ode.org/ontologies/galen#30.0\" AND (EXISTS \"http://www.co-ode.org/ontologies/galen#Attribute\".\"http://www.co-ode.org/ontologies/galen#5.0\" AND EXISTS \"http://www.co-ode.org/ontologies/galen#Attribute\".\"http://www.co-ode.org/ontologies/galen#6.0\")))"); OWLClassExpression input = KBParser.parseConcept("(\"http://www.co-ode.org/ontologies/galen#1.0\" AND (\"http://www.co-ode.org/ontologies/galen#10.0\" AND (EXISTS \"http://www.co-ode.org/ontologies/galen#DomainAttribute\".(\"http://www.co-ode.org/ontologies/galen#1.0\" AND (\"http://www.co-ode.org/ontologies/galen#6.0\" AND \"http://www.co-ode.org/ontologies/galen#TopCategory\")) AND EXISTS \"http://www.co-ode.org/ontologies/galen#Attribute\".(\"http://www.co-ode.org/ontologies/galen#1.0\" AND (\"http://www.co-ode.org/ontologies/galen#TopCategory\" AND EXISTS \"http://www.co-ode.org/ontologies/galen#Attribute\".TOP)))))"); input = ConceptTransformation.cleanConcept(input); ELDown operator = new ELDown(reasoner); operator.init(); operator.refine(input); }
reasoner.init(); } catch (ComponentInitException e) { e.printStackTrace();
reasoner.setPrecomputeObjectPropertyHierarchy(false); reasoner.setPrecomputeDataPropertyHierarchy(false); reasoner.init();
reasoner.init();
reasoner.init();
KnowledgeSource ks = new OWLFile(file); AbstractReasonerComponent reasoner = new OWLAPIReasoner(Collections.singleton(ks)); reasoner.init(); baseURI = reasoner.getBaseURI();
reasoner.setPrecomputeObjectPropertyHierarchy(true); reasoner.setPrecomputeDataPropertyHierarchy(true); reasoner.init();
reasoner.init(); reasoner.prepareSubsumptionHierarchy();
reasoner.init(); } catch (ComponentInitException e) { e.printStackTrace();
@Before public void setUp() throws Exception { String kb = "" + "@prefix : <http://dl-learner.org/test/> ." + "@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> ." + "@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> ." + ":x1 :r :y1 ." + ":x2 rdf:type :A ." + ":r rdfs:domain :A ." + ":x3 :s :y2 ." + ":x4 rdf:type :B ." + ":s rdfs:domain :C ." + ":B rdfs:subClassOf :C ." + ":x5 :t :y3 ." + ":y3 rdf:type :B ." + ":x6 :t :y4 ." + ":t rdfs:range :C ." + ":B rdfs:subClassOf :C ."; Model model = ModelFactory.createDefaultModel(); RDFDataMgr.read(model, new StringReader(kb), null, Lang.TURTLE); SparqlEndpointKS ks = new LocalModelBasedSparqlEndpointKS(model); ks.init(); AbstractReasonerComponent reasoner = new SPARQLReasoner(ks); reasoner.setPrecomputeClassHierarchy(true); reasoner.init(); cbdGenerator = new ConciseBoundedDescriptionGeneratorImpl(ks.getQueryExecutionFactory()); treeFactory = new QueryTreeFactoryBase(); lggGen = new LGGGeneratorRDFS(reasoner); }
KnowledgeSource ks = new OWLFile(file); AbstractReasonerComponent reasoner = new OWLAPIReasoner(Collections.singleton(ks)); reasoner.init(); baseURI = reasoner.getBaseURI();
@Test public void asTest() throws ComponentInitException, MalformedURLException { String ont = "../test/galen2.owl"; KnowledgeSource source = new OWLFile(ont); source.init(); AbstractReasonerComponent reasoner = new OWLAPIReasoner(Collections.singleton(source)); reasoner.init(); System.out.println("Galen loaded."); ELDescriptionTree tree = new ELDescriptionTree(reasoner); OWLClass a1 = new OWLClassImpl(IRI.create("http://www.co-ode.org/ontologies/galen#1.0")); OWLClass a2 = new OWLClassImpl(IRI.create("http://www.co-ode.org/ontologies/galen#10.0")); OWLClass a3 = new OWLClassImpl(IRI.create("http://www.co-ode.org/ontologies/galen#6.0")); OWLClass a4 = new OWLClassImpl(IRI.create("http://www.co-ode.org/ontologies/galen#TopCategory")); OWLObjectProperty r1 = new OWLObjectPropertyImpl(IRI.create("http://www.co-ode.org/ontologies/galen#Attribute")); OWLObjectProperty r2 = new OWLObjectPropertyImpl(IRI.create("http://www.co-ode.org/ontologies/galen#DomainAttribute")); ELDescriptionNode v1 = new ELDescriptionNode(tree, a1, a2); ELDescriptionNode v2 = new ELDescriptionNode(v1, r2, a1, a3, a4); ELDescriptionNode v3 = new ELDescriptionNode(v1, r1, a1, a4); new ELDescriptionNode(v3, r1); ELDescriptionNode w = new ELDescriptionNode(v2, r1); ELDown operator = new ELDown(reasoner); operator.init(); System.out.println(operator.asCheck(w)); }
reasoner.init();