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

项目:HermiT-android    文件:Reasoner.java   
protected void createPrefixes() {
    m_prefixes = new Prefixes();
    m_prefixes.declareSemanticWebPrefixes();
    Set<String> individualIRIs = new HashSet<String>();
    Set<String> anonIndividualIRIs = new HashSet<String>();
    for (Individual individual : m_dlOntology.getAllIndividuals())
        if (individual.isAnonymous())
            addIRI(individual.getIRI(), anonIndividualIRIs);
        else
            addIRI(individual.getIRI(), individualIRIs);
    m_prefixes.declareInternalPrefixes(individualIRIs, anonIndividualIRIs);
    m_prefixes.declareDefaultPrefix(m_dlOntology.getOntologyIRI() + "#");
    // declare prefixes as used in the ontology if possible
    OWLOntologyFormat format = m_rootOntology.getOWLOntologyManager()
            .getOntologyFormat(m_rootOntology);
    if (format instanceof PrefixOWLOntologyFormat) {
        PrefixOWLOntologyFormat prefixFormat = (PrefixOWLOntologyFormat) format;
        for (String prefixName : prefixFormat.getPrefixName2PrefixMap()
                .keySet()) {
            String prefix = prefixFormat.getPrefixName2PrefixMap().get(
                    prefixName);
            if (m_prefixes.getPrefixName(prefix) == null)
                try {
                    m_prefixes.declarePrefix(prefixName, prefix);
                } catch (IllegalArgumentException e) {
                    // ignore
                }
        }
    }
}
项目:Hermit_1.3.8_android    文件:Reasoner.java   
protected void createPrefixes() {
    m_prefixes = new Prefixes();
    m_prefixes.declareSemanticWebPrefixes();
    Set<String> individualIRIs = new HashSet<String>();
    Set<String> anonIndividualIRIs = new HashSet<String>();
    for (Individual individual : m_dlOntology.getAllIndividuals())
        if (individual.isAnonymous())
            addIRI(individual.getIRI(), anonIndividualIRIs);
        else
            addIRI(individual.getIRI(), individualIRIs);
    m_prefixes.declareInternalPrefixes(individualIRIs, anonIndividualIRIs);
    m_prefixes.declareDefaultPrefix(m_dlOntology.getOntologyIRI() + "#");
    // declare prefixes as used in the ontology if possible
    OWLOntologyFormat format = m_rootOntology.getOWLOntologyManager()
            .getOntologyFormat(m_rootOntology);
    if (format instanceof PrefixOWLOntologyFormat) {
        PrefixOWLOntologyFormat prefixFormat = (PrefixOWLOntologyFormat) format;
        for (String prefixName : prefixFormat.getPrefixName2PrefixMap()
                .keySet()) {
            String prefix = prefixFormat.getPrefixName2PrefixMap().get(
                    prefixName);
            if (m_prefixes.getPrefixName(prefix) == null)
                try {
                    m_prefixes.declarePrefix(prefixName, prefix);
                } catch (IllegalArgumentException e) {
                    // ignore
                }
        }
    }
}
项目: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);
    }
}