Java 类org.semanticweb.owlapi.model.OWLAnnotationSubject 实例源码

项目:owltools    文件:OWLGraphWrapperExtended.java   
/**
 * Find all corresponding {@link OWLObject}s with an OBO-style alternate identifier.
 * <p>
 * WARNING: This methods scans all object annotations in all ontologies. 
 * This is an expensive method.
 * 
 * @return map of altId to OWLObject (never null)
 */
public Map<String, OWLObject> getAllOWLObjectsByAltId() {
    final Map<String, OWLObject> results = new HashMap<String, OWLObject>();
    final OWLAnnotationProperty altIdProperty = getAnnotationProperty(OboFormatTag.TAG_ALT_ID.getTag());
    if (altIdProperty == null) {
        return Collections.emptyMap();
    }
    for (OWLOntology o : getAllOntologies()) {
        Set<OWLAnnotationAssertionAxiom> aas = o.getAxioms(AxiomType.ANNOTATION_ASSERTION);
        for (OWLAnnotationAssertionAxiom aa : aas) {
            OWLAnnotationValue v = aa.getValue();
            OWLAnnotationProperty property = aa.getProperty();
            if (altIdProperty.equals(property) && v instanceof OWLLiteral) {
                String altId = ((OWLLiteral)v).getLiteral();
                OWLAnnotationSubject subject = aa.getSubject();
                if (subject instanceof IRI) {
                    OWLObject obj = getOWLObject((IRI) subject);
                    if (obj != null) {
                        results.put(altId, obj);
                    }
                }
            }
        }
    }
    return results;
}
项目:owltools    文件:OWLGraphWrapperExtended.java   
/**
 * Find the corresponding {@link OWLObject}s for a given set of OBO-style alternate identifiers.
 * <p>
 * WARNING: This methods scans all object annotations in all ontologies. 
 * This is an expensive method.
 * <p>
 * Consider loading all altId-mappings using {@link #getAllOWLObjectsByAltId()}.
 * 
 * @param altIds
 * @return map of altId to OWLObject (never null)
 * @see #getAllOWLObjectsByAltId()
 */
public Map<String, OWLObject> getOWLObjectsByAltId(Set<String> altIds) {
    final Map<String, OWLObject> results = new HashMap<String, OWLObject>();
    final OWLAnnotationProperty altIdProperty = getAnnotationProperty(OboFormatTag.TAG_ALT_ID.getTag());
    if (altIdProperty == null) {
        return Collections.emptyMap();
    }
    for (OWLOntology o : getAllOntologies()) {
        Set<OWLAnnotationAssertionAxiom> aas = o.getAxioms(AxiomType.ANNOTATION_ASSERTION);
        for (OWLAnnotationAssertionAxiom aa : aas) {
            OWLAnnotationValue v = aa.getValue();
            OWLAnnotationProperty property = aa.getProperty();
            if (altIdProperty.equals(property) && v instanceof OWLLiteral) {
                String altId = ((OWLLiteral)v).getLiteral();
                if (altIds.contains(altId)) {
                    OWLAnnotationSubject subject = aa.getSubject();
                    if (subject instanceof IRI) {
                        OWLObject obj = getOWLObject((IRI) subject);
                        if (obj != null) {
                            results.put(altId, obj);
                        }
                    }
                }
            }
        }
    }
    return results;
}
项目:owltools    文件:OWLGraphWrapperBasic.java   
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));
}
项目:relex    文件:OWLView.java   
/**
* Print out RelEx relations. All relations shown
* in a binary form.
*
* Example:
*       _subj(throw, John)
*       _obj(throw, ball)
*       tense(throw, past)
*       definite-FLAG(ball, T)
*       noun_number(ball, singular)
*/
public void printRelations(ParsedSentence parse, String sentence, int sentence_id, String ontologyname)
{
    try
    {
        sent = sentence;

        //Add the sentence to Sentence Class
        this.sentence_id = sentence_id;
        sentenceInd = factory.getOWLNamedIndividual(IRI.create(ontologyURI + "#" + "sentence_" + sentence_id));
        //OWLAnnotationProperty p = new OWLAnnotationPropertyImpl(IRI.create(sentence));

        //OWLAnnotation label = factory.getOWLAnnotation(sentence);
        OWLOntologyFormat ontologyFormat = manager.getOntologyFormat(ontology);
        OWLAnnotation label = (OWLAnnotation) factory.getOWLAnnotationProperty(sentence, (PrefixManager) ontologyFormat);

        OWLClassAssertionAxiom sentClass = factory.getOWLClassAssertionAxiom(this.sentence,sentenceInd);
        OWLAnnotationAssertionAxiom labelClass = factory.getOWLAnnotationAssertionAxiom((OWLAnnotationSubject) sentClass, label);
        manager.applyChange(new AddAxiom(ontology, sentClass));
        manager.applyChange(new AddAxiom(ontology, labelClass));

        printRelations(parse, null);

    }
    catch (OWLOntologyChangeException ex)
    {
        Logger.getLogger(OWLView.class.getName()).log(Level.SEVERE, null, ex);
    }
}
项目:owlapi-gwt    文件:OWLAnnotationAssertionAxiomImpl.java   
/**
 * @param subject
 *        subject for axiom
 * @param property
 *        annotation property
 * @param value
 *        annotation value
 * @param annotations
 *        annotations on the axiom
 */
public OWLAnnotationAssertionAxiomImpl(
        @Nonnull OWLAnnotationSubject subject,
        @Nonnull OWLAnnotationProperty property,
        @Nonnull OWLAnnotationValue value,
        @Nonnull Collection<? extends OWLAnnotation> annotations) {
    super(annotations);
    this.subject = checkNotNull(subject, "subject cannot be null");
    this.property = checkNotNull(property, "property cannot be null");
    this.value = checkNotNull(value, "value cannot be null");
}
项目:skoseditor    文件:SKOSAnnotationViewComponent.java   
public void initialiseIndividualsView() throws Exception {
    list = new OWLFrameList<OWLAnnotationSubject>(getOWLEditorKit(), new SKOSAnnotationFrame(getOWLEditorKit()));
    setLayout(new BorderLayout());
    add(new JScrollPane(list));
}
项目:elk-reasoner    文件:OwlConverter.java   
@SuppressWarnings("static-method")
public ElkAnnotationSubject convert(OWLAnnotationSubject subject) {
    return OWL_ANNOTATION_CONVERTER.visit(subject);
}
项目:elk-reasoner    文件:OwlAnnotationSubjectValueVisitor.java   
public ElkAnnotationSubject visit(OWLAnnotationSubject subject) {
    return subject.accept(this);
}
项目:elk-reasoner    文件:ElkConverter.java   
@Override
public OWLAnnotationSubject convert(ElkAnnotationSubject input) {
    return (OWLAnnotationSubject) input.accept(this);
}
项目:SciGraph    文件:GraphOwlVisitorTestBase.java   
@Before
public void setup() throws Exception {
  if (builtGraph) {
    // TODO: UGH - need a better pattern for this
    return;
  }
  graph = createInstance();

  String uri = Resources.getResource("ontologies/family.owl").toURI().toString();
  manager.loadOntologyFromOntologyDocument(IRI.create(uri));

  List<MappedProperty> propertyMap = new ArrayList<>();
  MappedProperty age = mock(MappedProperty.class);
  when(age.getName()).thenReturn("isAged");
  when(age.getProperties()).thenReturn(newArrayList(ROOT + "/hasAge"));
  propertyMap.add(age);
  MappedProperty versionInfo = mock(MappedProperty.class);
  when(versionInfo.getName()).thenReturn("versionInfo");
  when(versionInfo.getProperties()).thenReturn(newArrayList(OWL + "versionInfo"));
  propertyMap.add(versionInfo);
  OWLOntologyWalker walker = new OWLOntologyWalker(manager.getOntologies());
  GraphOwlVisitor visitor = new GraphOwlVisitor(walker, graph, propertyMap);
  walker.walkStructure(visitor);

  for (OWLOntology ontology : manager.getOntologies()){
    String ontologyIri = OwlApiUtils.getIri(ontology);
    for (OWLAnnotation annotation : ontology.getAnnotations()) { // Get annotations on ontology iri
      OWLAnnotationSubject ontologySubject = IRI.create(ontologyIri);
      OWLAnnotationAssertionAxiom object = 
          new OWLAnnotationAssertionAxiomImpl(ontologySubject,
              annotation.getProperty(), annotation.getValue(),
              new ArrayList<OWLAnnotation>());
      visitor.visit(object);
    }
  }
  graph.shutdown();
  graphDb = new TestGraphDatabaseFactory().newEmbeddedDatabase(new File(path));
  tx = graphDb.beginTx();
  nodeIndex = graphDb.index().getNodeAutoIndexer().getAutoIndex();
  builtGraph = true;
}
项目:owlapi-gwt    文件:OWLAnnotationAssertionAxiomImpl.java   
@Override
public OWLAnnotationSubject getSubject() {
    return subject;
}
项目:SVoNt    文件:Test.java   
/**
 * @param args
 */
public static void main(String[] args) {
    OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
    IRI iri = IRI.create(new File("/Users/ralph/Uni/Corporate Semantic Web/Arbeitspaket SVoNt/runtime-EclipseApplication/ChangelogTest4/ontology/ontology.owl"));
    try {
        OWLOntology ontology = manager.loadOntologyFromOntologyDocument(iri);

        IRI ontologyIRI = ontology.getOntologyID().getOntologyIRI();
        System.out.println(ontologyIRI);
        System.out.println();

        Set<OWLEntity> entities = ontology.getSignature();

        for (OWLEntity entity : entities) {
            System.out.println(entity + ":");

            Set<OWLAnnotationAssertionAxiom> axioms = entity.getAnnotationAssertionAxioms(ontology);
            for (OWLAnnotationAssertionAxiom axiom : axioms) {

                System.out.print(axiom.getClass().getName()+": ");
                System.out.print(axiom.getAxiomType() + ", ");
                System.out.println(axiom);

                OWLAnnotationSubject subject = axiom.getSubject();
                if (subject instanceof IRI) {
                    Set<OWLEntity> subjects = ontology.getEntitiesInSignature((IRI)subject);
                    if (subjects.size() != 1) {
                        System.out.println("Ooops, subject size is " + subjects.size());
                    } else {
                        OWLEntity subjectEntity = subjects.iterator().next();
                        System.out.println(subjectEntity);
                    }
                }

                System.out.println();
            }
            System.out.println();
        }


    } catch (OWLOntologyCreationException e) {
        e.printStackTrace();
    }

}
项目:elk-reasoner    文件:AbstractElkObjectConverter.java   
abstract OWLAnnotationSubject convert(ElkAnnotationSubject input);