本文整理汇总了Java中org.semanticweb.owlapi.model.OWLImportsDeclaration类的典型用法代码示例。如果您正苦于以下问题:Java OWLImportsDeclaration类的具体用法?Java OWLImportsDeclaration怎么用?Java OWLImportsDeclaration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OWLImportsDeclaration类属于org.semanticweb.owlapi.model包,在下文中一共展示了OWLImportsDeclaration类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: translate
import org.semanticweb.owlapi.model.OWLImportsDeclaration; //导入依赖的package包/类
/**
* Translate the given {@link GafDocument} into an OWL representation of the LEGO model.
*
* @param gaf
* @return lego ontology
* @throws OWLException
* @throws UnknownIdentifierException
*/
public OWLOntology translate(GafDocument gaf) throws OWLException, UnknownIdentifierException {
final OWLOntologyManager m = graph.getManager();
OWLOntology lego = m.createOntology(IRI.generateDocumentIRI());
OWLOntology sourceOntology = graph.getSourceOntology();
OWLOntologyID ontologyID = sourceOntology.getOntologyID();
if (ontologyID != null) {
Optional<IRI> ontologyIRI = ontologyID.getOntologyIRI();
if (ontologyIRI.isPresent()) {
OWLDataFactory f = m.getOWLDataFactory();
OWLImportsDeclaration importDeclaration = f.getOWLImportsDeclaration(ontologyIRI.get());
m.applyChange(new AddImport(lego, importDeclaration ));
}
}
translate(gaf.getGeneAnnotations(), lego);
return lego;
}
开发者ID:geneontology,项目名称:minerva,代码行数:25,代码来源:GafToLegoIndividualTranslator.java
示例2: OntologyMetadata
import org.semanticweb.owlapi.model.OWLImportsDeclaration; //导入依赖的package包/类
public OntologyMetadata(OWLOntology ont) {
super();
OWLOntologyID id = ont.getOntologyID();
if (id.getOntologyIRI().isPresent())
ontologyIRI = id.getOntologyIRI().get().toString();
if (id.getVersionIRI().isPresent())
versionIRI = id.getVersionIRI().get().toString();
importDirectives = new HashSet<String>();
for (OWLImportsDeclaration oid : ont.getImportsDeclarations()) {
importDirectives.add(oid.getIRI().toString());
}
classCount = ont.getClassesInSignature().size();
namedIndividualCount = ont.getIndividualsInSignature().size();
axiomCount = ont.getAxiomCount();
annotations = new HashSet<OntologyAnnotation>();
for (OWLAnnotation ann : ont.getAnnotations()) {
annotations.add(new OntologyAnnotation(ann));
}
}
开发者ID:owlcollab,项目名称:owltools,代码行数:20,代码来源:OntologyMetadata.java
示例3: addImportsFromSupportOntologies
import org.semanticweb.owlapi.model.OWLImportsDeclaration; //导入依赖的package包/类
public void addImportsFromSupportOntologies() {
OWLOntology sourceOntology = getSourceOntology();
OWLDataFactory factory = getDataFactory();
for (OWLOntology o : getSupportOntologySet()) {
Optional<IRI> ontologyIRI = o.getOntologyID().getOntologyIRI();
if (ontologyIRI.isPresent()) {
OWLImportsDeclaration importsDeclaration = factory.getOWLImportsDeclaration(ontologyIRI.get());
AddImport ai = new AddImport(sourceOntology, importsDeclaration);
LOG.info("Applying: "+ai);
getManager().applyChange(ai);
}
else {
String msg = "Could not add import due to missing ontology id: "+o;
LOG.error(msg);
throw new RuntimeException(msg);
}
}
this.setSupportOntologySet(new HashSet<OWLOntology>());
}
开发者ID:owlcollab,项目名称:owltools,代码行数:20,代码来源:OWLGraphWrapperBasic.java
示例4: mergeImportClosure
import org.semanticweb.owlapi.model.OWLImportsDeclaration; //导入依赖的package包/类
public void mergeImportClosure(boolean isRemovedImportsDeclarations) throws OWLOntologyCreationException {
OWLOntologyManager manager = getManager();
Set<OWLOntology> imports = sourceOntology.getImportsClosure();
for (OWLOntology o : imports) {
if (o.equals(sourceOntology))
continue;
String comment = "Includes "+summarizeOntology(o);
LOG.info(comment);
addCommentToOntology(sourceOntology, comment);
manager.addAxioms(sourceOntology, o.getAxioms());
}
Set<OWLImportsDeclaration> oids = sourceOntology.getImportsDeclarations();
for (OWLImportsDeclaration oid : oids) {
RemoveImport ri = new RemoveImport(sourceOntology, oid);
getManager().applyChange(ri);
}
}
开发者ID:owlcollab,项目名称:owltools,代码行数:20,代码来源:OWLGraphWrapperBasic.java
示例5: mergeSpecificImport
import org.semanticweb.owlapi.model.OWLImportsDeclaration; //导入依赖的package包/类
/**
* Merge a specific ontology from the import closure into the main ontology.
* Removes the import statement.
*
* @param ontologyIRI id of the ontology to merge
* @throws OWLOntologyCreationException
*/
public void mergeSpecificImport(IRI ontologyIRI) throws OWLOntologyCreationException {
OWLOntologyManager manager = getManager();
Set<OWLOntology> imports = sourceOntology.getImportsClosure();
for (OWLOntology o : imports) {
if (o.equals(sourceOntology))
continue;
Optional<IRI> currentIRI = o.getOntologyID().getOntologyIRI();
if (currentIRI.isPresent() && currentIRI.get().equals(ontologyIRI)) {
String comment = "Includes "+summarizeOntology(o);
LOG.info(comment);
addCommentToOntology(sourceOntology, comment);
manager.addAxioms(sourceOntology, o.getAxioms());
}
}
Set<OWLImportsDeclaration> oids = sourceOntology.getImportsDeclarations();
for (OWLImportsDeclaration oid : oids) {
if (ontologyIRI.equals(oid.getIRI())) {
RemoveImport ri = new RemoveImport(sourceOntology, oid);
getManager().applyChange(ri);
}
}
}
开发者ID:owlcollab,项目名称:owltools,代码行数:30,代码来源:OWLGraphWrapperBasic.java
示例6: handleSupportOntologies
import org.semanticweb.owlapi.model.OWLImportsDeclaration; //导入依赖的package包/类
private static List<OWLOntologyChange> handleSupportOntologies(OWLGraphWrapper graph)
{
OWLOntology ontology = graph.getSourceOntology();
OWLOntologyManager manager = ontology.getOWLOntologyManager();
OWLDataFactory factory = manager.getOWLDataFactory();
List<OWLOntologyChange> removeImportChanges = new ArrayList<OWLOntologyChange>();
Set<OWLOntology> supportOntologySet = graph.getSupportOntologySet();
for (OWLOntology support : supportOntologySet) {
Optional<IRI> supportIRI = support.getOntologyID().getOntologyIRI();
if(supportIRI.isPresent()) {
IRI ontologyIRI = supportIRI.get();
OWLImportsDeclaration importDeclaration = factory.getOWLImportsDeclaration(ontologyIRI);
ChangeApplied status = manager.applyChange(new AddImport(ontology, importDeclaration));
if (ChangeApplied.SUCCESSFULLY == status) {
// the change was successful, create remove import for later
removeImportChanges.add(new RemoveImport(ontology, importDeclaration));
}
}
}
return removeImportChanges;
}
开发者ID:owlcollab,项目名称:owltools,代码行数:23,代码来源:AssertInferenceTool.java
示例7: addOntologyStructure
import org.semanticweb.owlapi.model.OWLImportsDeclaration; //导入依赖的package包/类
void addOntologyStructure(OWLOntologyManager manager, OWLOntology ontology) {
long parent = graph.createNode(OwlApiUtils.getIri(ontology));
graph.addLabel(parent, OwlLabels.OWL_ONTOLOGY);
for (OWLImportsDeclaration importDeclaration : ontology.getImportsDeclarations()) {
OWLOntology childOnt = manager.getImportedOntology(importDeclaration);
if (null == childOnt) {
// TODO: Why is childOnt sometimes null (when importing rdf)?
continue;
}
long child = graph.createNode(OwlApiUtils.getIri(childOnt));
graph.addLabel(parent, OwlLabels.OWL_ONTOLOGY);
if (graph.getRelationship(child, parent, OwlRelationships.RDFS_IS_DEFINED_BY).isPresent()) {
continue;
}
graph.createRelationship(child, parent, OwlRelationships.RDFS_IS_DEFINED_BY);
addOntologyStructure(manager, childOnt);
}
}
开发者ID:SciGraph,项目名称:SciGraph,代码行数:19,代码来源:OwlOntologyProducer.java
示例8: testAnnotations
import org.semanticweb.owlapi.model.OWLImportsDeclaration; //导入依赖的package包/类
@Test
public void testAnnotations() throws Exception {
// setup test model/ontology
OWLOntology o = m.createOntology();
OWLImportsDeclaration importDeclaration = f.getOWLImportsDeclaration(g.getSourceOntology().getOntologyID().getOntologyIRI().get());
m.applyChange(new AddImport(o, importDeclaration));
final IRI i1IRI = IRI.generateDocumentIRI();
final OWLNamedIndividual ni1 = f.getOWLNamedIndividual(i1IRI);
// declare individual
m.addAxiom(o, f.getOWLDeclarationAxiom(ni1));
// add annotations
m.addAxiom(o, f.getOWLAnnotationAssertionAxiom(i1IRI,
f.getOWLAnnotation(f.getOWLAnnotationProperty(
AnnotationShorthand.comment.getAnnotationProperty()),
f.getOWLLiteral("Comment 1"))));
m.addAxiom(o, f.getOWLAnnotationAssertionAxiom(i1IRI,
f.getOWLAnnotation(f.getOWLAnnotationProperty(
AnnotationShorthand.comment.getAnnotationProperty()),
f.getOWLLiteral("Comment 2"))));
// declare type
m.addAxiom(o, f.getOWLClassAssertionAxiom(g.getOWLClassByIdentifier("GO:0000003"), ni1));
MolecularModelJsonRenderer r = new MolecularModelJsonRenderer(null, o, null, curieHandler);
JsonOwlIndividual jsonOwlIndividualOriginal = r.renderObject(ni1);
assertEquals(2, jsonOwlIndividualOriginal.annotations.length);
String json = MolecularModelJsonRenderer.renderToJson(jsonOwlIndividualOriginal, true);
JsonOwlIndividual jsonOwlIndividualParse = MolecularModelJsonRenderer.parseFromJson(json, JsonOwlIndividual.class);
assertNotNull(jsonOwlIndividualParse);
assertEquals(jsonOwlIndividualOriginal, jsonOwlIndividualParse);
}
开发者ID:geneontology,项目名称:minerva,代码行数:36,代码来源:MolecularModelJsonRendererTest.java
示例9: testSimpleClassExpression
import org.semanticweb.owlapi.model.OWLImportsDeclaration; //导入依赖的package包/类
private void testSimpleClassExpression(OWLClassExpression ce, String expectedJsonType) throws Exception {
// setup test model/ontology
OWLOntology o = m.createOntology();
OWLImportsDeclaration importDeclaration = f.getOWLImportsDeclaration(g.getSourceOntology().getOntologyID().getOntologyIRI().get());
m.applyChange(new AddImport(o, importDeclaration));
// create indivdual with a ce type
final IRI i1IRI = IRI.generateDocumentIRI();
final OWLNamedIndividual ni1 = f.getOWLNamedIndividual(i1IRI);
// declare individual
m.addAxiom(o, f.getOWLDeclarationAxiom(ni1));
// declare type
m.addAxiom(o, f.getOWLClassAssertionAxiom(ce, ni1));
MolecularModelJsonRenderer r = new MolecularModelJsonRenderer(null, o, null, curieHandler);
JsonOwlIndividual jsonOwlIndividualOriginal = r.renderObject(ni1);
String json = MolecularModelJsonRenderer.renderToJson(jsonOwlIndividualOriginal, true);
assertTrue(json, json.contains("\"type\": \""+expectedJsonType+"\""));
JsonOwlIndividual jsonOwlIndividualParse = MolecularModelJsonRenderer.parseFromJson(json, JsonOwlIndividual.class);
assertNotNull(jsonOwlIndividualParse);
assertEquals(jsonOwlIndividualOriginal, jsonOwlIndividualParse);
Set<OWLClassExpression> ces = TestJsonOwlObjectParser.parse(new OWLGraphWrapper(o), jsonOwlIndividualParse.type);
assertEquals(1, ces.size());
assertEquals(ce, ces.iterator().next());
}
开发者ID:geneontology,项目名称:minerva,代码行数:32,代码来源:MolecularModelJsonRendererTest.java
示例10: addImport
import org.semanticweb.owlapi.model.OWLImportsDeclaration; //导入依赖的package包/类
@Deprecated
public void addImport(String importedIRIString) {
OWLImportsDeclaration iax = dataFactory.getOWLImportsDeclaration(IRI.create(importedIRIString));
//AddImport addAx = new AddImport(ontology, iax);
AddImport addAx = new AddImport(getOntology(), iax);
manager.applyChange(addAx);
}
开发者ID:owlcollab,项目名称:owltools,代码行数:8,代码来源:Mooncat.java
示例11: mergeOntology
import org.semanticweb.owlapi.model.OWLImportsDeclaration; //导入依赖的package包/类
public void mergeOntology(OWLOntology extOnt, LabelPolicy labelPolicy) throws OWLOntologyCreationException {
OWLOntologyManager manager = getManager();
LOG.info("Merging "+extOnt+" policy: "+labelPolicy);
for (OWLAxiom axiom : extOnt.getAxioms()) {
if (labelPolicy != LabelPolicy.ALLOW_DUPLICATES) {
if (axiom instanceof OWLAnnotationAssertionAxiom) {
OWLAnnotationAssertionAxiom aa = (OWLAnnotationAssertionAxiom)axiom;
if (aa.getProperty().isLabel()) {
OWLAnnotationSubject subj = aa.getSubject();
if (subj instanceof IRI) {
Optional<OWLLiteral> label = null;
for (OWLAnnotationAssertionAxiom a1 : sourceOntology.getAnnotationAssertionAxioms(subj)) {
if (a1.getProperty().isLabel()) {
label = a1.getValue().asLiteral();
}
}
if (label != null && label.isPresent()) {
if (labelPolicy == LabelPolicy.PRESERVE_SOURCE) {
LOG.info("Preserving existing label:" +subj+" "+label+" // ditching: "+axiom);
continue;
}
if (labelPolicy == LabelPolicy.PRESERVE_EXT) {
LOG.info("Replacing:" +subj+" "+label+" with: "+axiom);
LOG.error("NOT IMPLEMENTED");
}
}
}
}
}
}
manager.applyChange(new AddAxiom(sourceOntology, axiom));
}
for (OWLImportsDeclaration oid: extOnt.getImportsDeclarations()) {
manager.applyChange(new AddImport(sourceOntology, oid));
}
addCommentToOntology(sourceOntology, "Includes "+summarizeOntology(extOnt));
}
开发者ID:owlcollab,项目名称:owltools,代码行数:38,代码来源:OWLGraphWrapperBasic.java
示例12: convertSet
import org.semanticweb.owlapi.model.OWLImportsDeclaration; //导入依赖的package包/类
private Object[] convertSet(Set objs) {
Object[] arr = new Object[objs.size()];
int i=0;
for (Object obj : objs) {
if (obj instanceof OWLAxiom)
arr[i] = convert((OWLAxiom) obj);
else if (obj instanceof OWLImportsDeclaration)
arr[i] = convert((OWLImportsDeclaration) obj);
else
arr[i] = convert((OWLObject) obj);
i++;
}
return arr;
}
开发者ID:owlcollab,项目名称:owltools,代码行数:15,代码来源:OWLGsonRenderer.java
示例13: test
import org.semanticweb.owlapi.model.OWLImportsDeclaration; //导入依赖的package包/类
@Test
public void test() throws Exception {
// load the base ontology
ParserWrapper pw = new ParserWrapper();
OWLOntology direct = pw.parseOBO(getResourceIRIString("graph/xref_test.obo"));
OWLGraphWrapper directGraph = new OWLGraphWrapper(direct);
// check that the test class has the expected number of xrefs
OWLClass c = directGraph.getOWLClassByIdentifier("FOO:0001");
List<String> directDefXrefs = directGraph.getDefXref(c);
assertEquals(2, directDefXrefs.size());
List<String> directXrefs = directGraph.getXref(c);
assertEquals(2, directXrefs.size());
// create an ontology using an import
OWLOntologyManager manager = pw.getManager();
OWLDataFactory factory = manager.getOWLDataFactory();
OWLOntology importer = manager.createOntology();
OWLImportsDeclaration importDeclaration = factory.getOWLImportsDeclaration(direct.getOntologyID().getOntologyIRI().orNull());
manager.applyChange(new AddImport(importer, importDeclaration));
OWLGraphWrapper importerGraph = new OWLGraphWrapper(importer);
// check that the wrapper uses also imports for lookups of xrefs
List<String> importedDefXrefs = importerGraph.getDefXref(c);
assertEquals(2, importedDefXrefs.size());
List<String> importedXrefs = importerGraph.getXref(c);
assertEquals(2, importedXrefs.size());
}
开发者ID:owlcollab,项目名称:owltools,代码行数:34,代码来源:ImportedXrefTest.java
示例14: equals
import org.semanticweb.owlapi.model.OWLImportsDeclaration; //导入依赖的package包/类
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof OWLImportsDeclaration)) {
return false;
}
OWLImportsDeclaration other = (OWLImportsDeclaration) obj;
return iri.equals(other.getIRI());
}
开发者ID:matthewhorridge,项目名称:owlapi-gwt,代码行数:12,代码来源:OWLImportsDeclarationImpl.java
示例15: BinaryOWLImportsDeclarationSet
import org.semanticweb.owlapi.model.OWLImportsDeclaration; //导入依赖的package包/类
public BinaryOWLImportsDeclarationSet(BinaryOWLInputStream inputStream) throws IOException, BinaryOWLParseException {
int size = inputStream.readInt();
if(size == 0) {
importsDeclarations = Collections.emptySet();
}
else {
Set<OWLImportsDeclaration> read = new LinkedHashSet<OWLImportsDeclaration>(size);
for(int i = 0; i < size; i++) {
BinaryOWLImportsDeclaration binDecl = new BinaryOWLImportsDeclaration(inputStream);
read.add(binDecl.getImportsDeclaration());
}
importsDeclarations = Collections.unmodifiableSet(read);
}
}
开发者ID:matthewhorridge,项目名称:binaryowl,代码行数:16,代码来源:BinaryOWLImportsDeclarationSet.java
示例16: write
import org.semanticweb.owlapi.model.OWLImportsDeclaration; //导入依赖的package包/类
public void write(BinaryOWLOutputStream dataOutput) throws IOException {
dataOutput.writeInt(importsDeclarations.size());
for(OWLImportsDeclaration declaration : importsDeclarations) {
BinaryOWLImportsDeclaration binDecl = new BinaryOWLImportsDeclaration(declaration);
binDecl.write(dataOutput);
}
}
开发者ID:matthewhorridge,项目名称:binaryowl,代码行数:8,代码来源:BinaryOWLImportsDeclarationSet.java
示例17: testUpdateImports
import org.semanticweb.owlapi.model.OWLImportsDeclaration; //导入依赖的package包/类
@Test
public void testUpdateImports() throws Exception {
final OWLOntologyManager m = OWLManager.createOWLOntologyManager();
final OWLDataFactory f = m.getOWLDataFactory();
// setup other import
final IRI other = IRI.generateDocumentIRI();
m.createOntology(other);
// setup additional
final IRI add1 = IRI.generateDocumentIRI();
m.createOntology(add1);
final IRI add2 = IRI.generateDocumentIRI();
m.createOntology(add2);
final Set<IRI> additional = new HashSet<IRI>();
additional.add(add1);
additional.add(add2);
// setup tbox
final IRI tboxIRI = IRI.generateDocumentIRI();
m.createOntology(tboxIRI);
// setup abox
final OWLOntology abox = m.createOntology(IRI.generateDocumentIRI());
// add initial imports to abox
m.applyChange(new AddImport(abox, f.getOWLImportsDeclaration(other)));
// update imports
CoreMolecularModelManager.updateImports(abox, tboxIRI, additional);
// check the resulting imports
Set<OWLImportsDeclaration> declarations = abox.getImportsDeclarations();
assertEquals(4, declarations.size());
Set<IRI> declaredImports = new HashSet<IRI>();
for (OWLImportsDeclaration importsDeclaration : declarations) {
declaredImports.add(importsDeclaration.getIRI());
}
assertEquals(4, declaredImports.size());
assertTrue(declaredImports.contains(tboxIRI));
assertTrue(declaredImports.contains(add1));
assertTrue(declaredImports.contains(add1));
assertTrue(declaredImports.contains(other));
}
开发者ID:geneontology,项目名称:minerva,代码行数:44,代码来源:CoreMolecularModelManagerTest.java
示例18: visit
import org.semanticweb.owlapi.model.OWLImportsDeclaration; //导入依赖的package包/类
public void visit(OWLImportsDeclaration axiom) {
}
开发者ID:robertoyus,项目名称:HermiT-android,代码行数:3,代码来源:OWLNormalization.java
示例19: visit
import org.semanticweb.owlapi.model.OWLImportsDeclaration; //导入依赖的package包/类
public Boolean visit(OWLImportsDeclaration axiom) {
return Boolean.TRUE;
}
开发者ID:robertoyus,项目名称:HermiT-android,代码行数:4,代码来源:EntailmentChecker.java
示例20: testRemovingImpA
import org.semanticweb.owlapi.model.OWLImportsDeclaration; //导入依赖的package包/类
/**
* Testing correctness of the reasoner with respect to ontology changes
* <p>
* removing the import declaration for </impA>
*/
@Test
public void testRemovingImpA() throws Exception {
OWLOntologyManager man = TestOWLManager.createOWLOntologyManager();
OWLDataFactory dataFactory = man.getOWLDataFactory();
// set up resolution of prefixes
PrefixManager pm = new DefaultPrefixManager();
pm.setDefaultPrefix("http://www.example.com/main#");
pm.setPrefix("A:", "http://www.example.com/A#");
pm.setPrefix("B:", "http://www.example.com/B#");
// define query classes
OWLClass mainX = dataFactory.getOWLClass(":X", pm);
OWLClass mainY = dataFactory.getOWLClass(":Y", pm);
OWLClass extA = dataFactory.getOWLClass("A:A", pm);
OWLClass extB = dataFactory.getOWLClass("B:B", pm);
OWLClass extC = dataFactory.getOWLClass("B:C", pm);
// loading the root ontology
OWLOntology root = loadOntology(man, "root.owl");
// Create an ELK reasoner.
OWLReasonerFactory reasonerFactory = new ElkReasonerFactory();
OWLReasoner reasoner = reasonerFactory.createReasoner(root);
try {
// ************************************
// ** removing the import declaration for </impA>
// ************************************
OWLImportsDeclaration importA = new OWLImportsDeclarationImpl(
IRI.create("http://www.example.com#impA"));
OWLOntologyChange change = new RemoveImport(root, importA);
man.applyChange(change);
reasoner.flush();
// Now the root ontology should not import anything
assertEquals(root.getAxiomCount(), 3);
assertEquals(root.getImportsClosure().size(), 1);
assertEquals(getAxioms(root).size(), 3);
// reasoner queries -- only subsumptions of the root ontology are
// there
assertTrue(reasoner.getSuperClasses(mainX, true).containsEntity(
mainY));
assertTrue(reasoner.getSuperClasses(mainX, true).containsEntity(
extA));
assertTrue(reasoner.getSuperClasses(mainY, true).containsEntity(
extB));
assertFalse(reasoner.getSuperClasses(extA, true).containsEntity(
extB));
assertFalse(reasoner.getSuperClasses(extB, true).containsEntity(
extC));
} finally {
reasoner.dispose();
}
}
开发者ID:liveontologies,项目名称:elk-reasoner,代码行数:67,代码来源:ElkReasonerTest.java
注:本文中的org.semanticweb.owlapi.model.OWLImportsDeclaration类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论