本文整理汇总了Java中org.semanticweb.owlapi.model.OWLImportsDeclaration类的典型用法代码示例。如果您正苦于以下问题:Java OWLImportsDeclaration类的具体用法?Java OWLImportsDeclaration怎么用?Java OWLImportsDeclaration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OWLImportsDeclaration类属于org.semanticweb.owlapi.model包,在下文中一共展示了OWLImportsDeclaration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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));
}
}
示例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>());
}
示例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);
}
}
示例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);
}
}
}
示例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;
}
示例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);
}
}
示例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);
}
示例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());
}
示例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);
}
示例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));
}
示例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;
}
示例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());
}
示例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());
}
示例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);
}
}