@Override public OWLNamedIndividual getOWLNamedIndividual(IRI iri) { return new OWLNamedIndividualImpl(iri); }
@Override public OWLNamedIndividual getOWLNamedIndividual(IRI iri) { return new OWLNamedIndividualImpl(iri); }
@Override public OWLNamedIndividual getOWLNamedIndividual(IRI iri) { return new OWLNamedIndividualImpl(iri); }
@Override public OWLNamedIndividual getOWLNamedIndividual(IRI iri) { return new OWLNamedIndividualImpl(iri); }
@Override public OWLNamedIndividual getOWLNamedIndividual(IRI iri) { return new OWLNamedIndividualImpl(iri); }
@Override public OWLNamedIndividual getOWLNamedIndividual(IRI iri) { return new OWLNamedIndividualImpl(iri); }
public OWLNamedIndividual getOWLNamedIndividual(IRI iri) { OWLNamedIndividual ind = individualsByURI.get(iri); if (ind == null) { ind = new OWLNamedIndividualImpl(this, iri); individualsByURI.put(iri, ind); } return ind; }
public static Set<OWLIndividual> readExamples(String filePath) throws IOException { Set<OWLIndividual> indivs = new TreeSet<>(); try(BufferedReader buffRead = new BufferedReader(new FileReader(new File(filePath)))){ String line; while ((line = buffRead.readLine()) != null) { line = line.trim(); line = line.substring(1, line.length()-1); // strip off angle brackets indivs.add(new OWLNamedIndividualImpl(IRI.create(line))); } } return indivs; } private static void setUp() {
private static Set<OWLIndividual> makeIndividuals(List<String> uris) { Set<OWLIndividual> individuals = new HashSet<>(); for (String uri : uris) { individuals.add(new OWLNamedIndividualImpl(IRI.create(uri))); } return individuals; } }
public static Set<OWLIndividual> makeExamples(Set<String> uris) { Set<OWLIndividual> indivs = new TreeSet<>(); for (String uri : uris) { indivs.add(new OWLNamedIndividualImpl(IRI.create(uri))); } return indivs; } public static Set<OWLIndividual> readExamples(String filePath) throws IOException {
private static Set<OWLIndividual> makeIndividuals(List<String> uris) { Set<OWLIndividual> individuals = new HashSet<>(); for (String uri : uris) { individuals.add(new OWLNamedIndividualImpl(IRI.create(uri))); } return individuals; } }
public static Set<OWLIndividual> readExamples(String filePath) throws IOException { Set<OWLIndividual> indivs = new TreeSet<>(); try(BufferedReader buffRead = new BufferedReader(new FileReader(new File(filePath)))){ String line; while ((line = buffRead.readLine()) != null) { line = line.trim(); line = line.substring(1, line.length()-1); // strip off angle brackets indivs.add(new OWLNamedIndividualImpl(IRI.create(line))); } } return indivs; } private static void setUp() {
/** * * @param id The session ID. * @param negativeExamples * @throws ClientNotKnownException Thrown if client (session ID) is not known. */ @WebMethod public void setNegativeExamples(int id, String[] negativeExamples) throws ClientNotKnownException { ClientState state = getState(id); Set<String> negExamples = new TreeSet<>(Arrays.asList(negativeExamples)); Set<OWLIndividual> inds = new HashSet<>(); for (String ex : negExamples) { inds.add(new OWLNamedIndividualImpl(IRI.create(ex))); } ((PosNegLP)state.getLearningProblem()).setNegativeExamples(inds); }
public static OWLNamedIndividualImpl instantiate(SerializationStreamReader streamReader) throws SerializationException { return new OWLNamedIndividualImpl(IRI.create(streamReader.readString())); }
/** * Returns the classes of the ontology that are also used as individuals, i.e. types of other classes. * @param ontology the ontology * @return the classes */ public static Set<OWLClass> getPunningClasses(OWLOntology ontology){ Set<OWLClass> classes = new HashSet<>(); Set<OWLNamedIndividual> individualsInSignature = ontology.getIndividualsInSignature(); for (OWLClass cls : ontology.getClassesInSignature()) { if(individualsInSignature.contains(new OWLNamedIndividualImpl(cls.getIRI()))){ classes.add(cls); } // for (OWLNamedIndividual ind : ontology.getIndividualsInSignature()) { // if(cls.getIRI().equals(ind.getIRI())){ // classes.add(cls); // break; // } // } } return classes; }
private Set<OWLIndividual> computePosExamples(OWLClass cls) { List<OWLIndividual> posExamples = new ArrayList<>(); String query = String.format("SELECT ?s WHERE {?s a <%s>}", cls.toStringID()); try(QueryExecution qe = qef.createQueryExecution(query)) { ResultSet rs = qe.execSelect(); while(rs.hasNext()) { QuerySolution qs = rs.next(); posExamples.add(new OWLNamedIndividualImpl(IRI.create(qs.getResource("s").getURI()))); } } Collections.shuffle(posExamples, rnd); return new TreeSet<>(posExamples.subList(0, Math.min(posExamples.size(), maxNrOfPosExamples))); }
/** * Returns the classes of the ontology that are also used as individuals, i.e. types of other classes. * @param ontology the ontology * @return the classes */ public static Set<IRI> getPunningIRIs(OWLOntology ontology){ Set<IRI> classes = new HashSet<>(); Set<OWLNamedIndividual> individualsInSignature = ontology.getIndividualsInSignature(); for (OWLClass cls : ontology.getClassesInSignature()) { if(individualsInSignature.contains(new OWLNamedIndividualImpl(cls.getIRI()))){ classes.add(cls.getIRI()); } // for (OWLNamedIndividual ind : ontology.getIndividualsInSignature()) { // if(cls.getIRI().equals(ind.getIRI())){ // classes.add(cls); // break; // } // } } return classes; }
boolean inTBoxBefore = inTBox; inTBox = true; new OWLNamedIndividualImpl(cls.getIRI()).accept(this); inTBox = inTBoxBefore;
/** * * @param id The session ID. * @param positiveExamples * @throws ClientNotKnownException Thrown if client (session ID) is not known. */ @WebMethod public void setPositiveExamples(int id, String[] positiveExamples) throws ClientNotKnownException { ClientState state = getState(id); Set<String> posExamples = new TreeSet<>(Arrays.asList(positiveExamples)); SortedSet<OWLIndividual> inds = new TreeSet<>(); for (String ex : posExamples) { inds.add(new OWLNamedIndividualImpl(IRI.create(ex))); } if (state.getLearningProblem() instanceof PosOnlyLP) { ((PosOnlyLP)state.getLearningProblem()).setPositiveExamples(inds); } else { ((PosNegLP)state.getLearningProblem()).setPositiveExamples(inds); } }
@Test public void entityDetection() { AbstractReasonerComponent reasoner = TestOntologies.getTestOntology(TestOntology.DATA1); int maxDepth = 2; Set<OWLIndividual> individuals = new TreeSet<>(); individuals.add(new OWLNamedIndividualImpl(IRI.create("http://localhost/foo#tim"))); UsedEntitiesDetection detection = new UsedEntitiesDetection(reasoner, individuals, maxDepth); System.out.println(detection); }