use of org.semanticweb.owlapi.model.OWLOntologyManager in project stanbol by apache.
the class DatavaluedPropertyAtomTest method setup.
@Before
public void setup() {
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
this.factory = manager.getOWLDataFactory();
datatypeProperty = new ResourceAtom(URI.create("http://kres.iks-project.eu/ontology/meta/resource#hasTest"));
argument1 = new VariableAtom(URI.create("http://kres.iks-project.eu/ontology/meta/variables#x"), true);
variable = new VariableAtom(URI.create("http://kres.iks-project.eu/ontology/meta/variables#x"), false);
literal = new StringAtom("some text");
try {
typedLiteral = new TypedLiteralAtom(new NumberAtom("3.0"), new ResourceAtom(new URI(XSD.xdouble.getURI())));
} catch (URISyntaxException e) {
e.printStackTrace();
}
}
use of org.semanticweb.owlapi.model.OWLOntologyManager in project stanbol by apache.
the class ConversionTester method testDataPropOwlToJena.
public void testDataPropOwlToJena() {
JenaToOwlConvert j2o = new JenaToOwlConvert();
OWLOntologyManager mgr = OWLManager.createOWLOntologyManager();
OWLDataFactory factory = mgr.getOWLDataFactory();
OWLDataProperty dp = factory.getOWLDataProperty(IRI.create(DP));
DatatypeProperty jdp = null;
try {
jdp = j2o.DataPropOwlToJena(dp, RDFXML);
if (jdp == null) {
fail("Some errors accour");
} else {
assertEquals(jdp.getURI(), dp.getIRI().toString());
}
} catch (Exception e) {
e.printStackTrace();
fail("Exception caught");
} finally {
assertNotNull(jdp);
}
}
use of org.semanticweb.owlapi.model.OWLOntologyManager in project stanbol by apache.
the class ConversionTester method testEntityOwlToJenaResource.
public void testEntityOwlToJenaResource() {
JenaToOwlConvert j2o = new JenaToOwlConvert();
OWLOntologyManager mgr = OWLManager.createOWLOntologyManager();
OWLOntology ont = null;
StmtIterator resource = null;
try {
ont = mgr.createOntology();
} catch (OWLOntologyCreationException e) {
e.printStackTrace();
fail("Could not load ontology");
}
OWLDataFactory factory = mgr.getOWLDataFactory();
OWLClass cls = factory.getOWLClass(IRI.create(CLAZZ));
OWLDataProperty dp = factory.getOWLDataProperty(IRI.create(DP));
OWLObjectProperty op = factory.getOWLObjectProperty(IRI.create(OP));
OWLAnnotationProperty oa = factory.getOWLAnnotationProperty(IRI.create(label));
OWLAnnotation oav = factory.getOWLAnnotation(oa, factory.getOWLStringLiteral(clazzlabel, "en"));
OWLDatatype dt = factory.getOWLDatatype(IRI.create(DATATYPE));
OWLNamedIndividual sub = factory.getOWLNamedIndividual(IRI.create(SUBJECT));
OWLNamedIndividual obj = factory.getOWLNamedIndividual(IRI.create(OBJECT));
OWLLiteral literal1 = factory.getOWLTypedLiteral(VALUE, dt);
// Classe
OWLDeclarationAxiom daxiomcls = factory.getOWLDeclarationAxiom(cls);
// obj prop
OWLDeclarationAxiom daxiomop = factory.getOWLDeclarationAxiom(op);
// data prop
OWLDeclarationAxiom daxiomdp = factory.getOWLDeclarationAxiom(dp);
// subject
OWLDeclarationAxiom daxiomsub = factory.getOWLDeclarationAxiom(sub);
// object
OWLDeclarationAxiom daxiomobj = factory.getOWLDeclarationAxiom(obj);
// Istanza
OWLClassAssertionAxiom axiomsub = factory.getOWLClassAssertionAxiom(cls, sub);
// Istanza
OWLClassAssertionAxiom axiomobj = factory.getOWLClassAssertionAxiom(cls, obj);
// Obj
OWLObjectPropertyAssertionAxiom axiomop = factory.getOWLObjectPropertyAssertionAxiom(op, sub, obj);
// prop
// tra
// individui
OWLDataPropertyAssertionAxiom axiomvalue = factory.getOWLDataPropertyAssertionAxiom(dp, sub, // Dataprop all'istanza;
literal1);
// Annotazione
OWLAnnotationAssertionAxiom axioman = factory.getOWLAnnotationAssertionAxiom(cls.getIRI(), oav);
mgr.addAxiom(ont, daxiomcls);
mgr.addAxiom(ont, daxiomop);
mgr.addAxiom(ont, daxiomdp);
mgr.addAxiom(ont, daxiomsub);
mgr.addAxiom(ont, daxiomobj);
mgr.addAxiom(ont, axiomsub);
mgr.addAxiom(ont, axiomobj);
mgr.addAxiom(ont, axiomop);
mgr.addAxiom(ont, axiomvalue);
mgr.addAxiom(ont, axioman);
Set<OWLIndividualAxiom> ind = ont.getAxioms(sub);
try {
resource = j2o.EntityOwlToJenaResource(daxiomsub.getEntity(), ont, RDFXML);
if (resource == null) {
fail("Some errors accour");
} else {
int cont = 0;
while (resource.hasNext()) {
Statement stm = resource.nextStatement();
IRI subres = IRI.create(stm.getSubject().getURI());
if (("<" + subres + ">").equals(daxiomsub.getEntity().toString()))
cont++;
}
assertEquals(ind.size(), (cont - 1));
}
} catch (Exception e) {
e.printStackTrace();
fail("Exception caugth");
} finally {
assertNotNull(resource);
}
}
use of org.semanticweb.owlapi.model.OWLOntologyManager in project stanbol by apache.
the class ConversionTester method testObjPropOwlToJena.
public void testObjPropOwlToJena() {
JenaToOwlConvert j2o = new JenaToOwlConvert();
OWLOntologyManager mgr = OWLManager.createOWLOntologyManager();
OWLDataFactory factory = mgr.getOWLDataFactory();
OWLObjectProperty op = factory.getOWLObjectProperty(IRI.create(OP));
ObjectProperty jop = null;
try {
jop = j2o.ObjPropOwlToJena(op, RDFXML);
if (jop == null) {
fail("Some errore occurs");
} else {
assertEquals(jop.getURI(), op.getIRI().toString());
}
} catch (Exception e) {
e.printStackTrace();
fail("Exception caught");
} finally {
assertNotNull(jop);
}
}
use of org.semanticweb.owlapi.model.OWLOntologyManager in project stanbol by apache.
the class ConversionTester method testModelOwlToJenaConvert.
public void testModelOwlToJenaConvert() {
JenaToOwlConvert j2o = new JenaToOwlConvert();
OWLOntologyManager mgr = OWLManager.createOWLOntologyManager();
OWLOntologyManager mgrf = OWLManager.createOWLOntologyManager();
OWLDataFactory factory = mgrf.getOWLDataFactory();
String dul = "http://www.loa-cnr.it/ontologies/DUL.owl";
OWLOntology owl = null;
OntModel jena = null;
try {
owl = mgr.loadOntologyFromOntologyDocument(IRI.create(dul));
} catch (OWLOntologyCreationException e) {
e.printStackTrace();
fail("Could not load ontology");
}
try {
jena = j2o.ModelOwlToJenaConvert(owl, "RDF/XML");
if (jena == null) {
fail("Some errors occur");
} else {
ExtendedIterator<OntClass> jenaclass = jena.listNamedClasses();
int jenaclassset = jenaclass.toSet().size();
jenaclass = jena.listNamedClasses();
Set<OWLClass> owlclass = owl.getClassesInSignature();
int countclass = 0;
while (jenaclass.hasNext()) if (owlclass.contains(factory.getOWLClass(IRI.create(jenaclass.next().getURI()))))
countclass++;
if (countclass == jenaclassset)
assertEquals(countclass, jenaclassset);
else
fail("Error in number of classes");
ExtendedIterator<ObjectProperty> jenaprop = jena.listObjectProperties();
int jenapropset = jenaprop.toSet().size();
jenaprop = jena.listObjectProperties();
Set<OWLObjectProperty> owlprop = owl.getObjectPropertiesInSignature();
int countprop = 0;
while (jenaprop.hasNext()) if (owlprop.contains(factory.getOWLObjectProperty(IRI.create(jenaprop.next().getURI()))))
countprop++;
if (countprop == jenapropset)
assertEquals(countprop, jenapropset);
else
fail("Error in number of object properties");
ExtendedIterator<DatatypeProperty> jenadata = jena.listDatatypeProperties();
int jenadataset = jenadata.toSet().size();
jenadata = jena.listDatatypeProperties();
Set<OWLDataProperty> owldata = owl.getDataPropertiesInSignature();
int countdata = 0;
while (jenadata.hasNext()) if (owldata.contains(factory.getOWLDataProperty(IRI.create(jenadata.next().getURI()))))
countdata++;
if (countdata == jenadataset)
assertEquals(countdata, jenadataset);
else
fail("Error in number of data properties");
}
} catch (Exception e) {
e.printStackTrace();
fail("Exception caugth");
} finally {
assertNotNull(jena);
}
}
Aggregations