當前位置: 首頁>>代碼示例>>Java>>正文


Java OWLDataFactory.getOWLClassAssertionAxiom方法代碼示例

本文整理匯總了Java中org.semanticweb.owlapi.model.OWLDataFactory.getOWLClassAssertionAxiom方法的典型用法代碼示例。如果您正苦於以下問題:Java OWLDataFactory.getOWLClassAssertionAxiom方法的具體用法?Java OWLDataFactory.getOWLClassAssertionAxiom怎麽用?Java OWLDataFactory.getOWLClassAssertionAxiom使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.semanticweb.owlapi.model.OWLDataFactory的用法示例。


在下文中一共展示了OWLDataFactory.getOWLClassAssertionAxiom方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: isSatisfiable

import org.semanticweb.owlapi.model.OWLDataFactory; //導入方法依賴的package包/類
public boolean isSatisfiable(OWLClassExpression classExpression) {
	checkPreConditions(classExpression);
	if (!isConsistent())
		return false;
	if (classExpression instanceof OWLClass
			&& m_atomicConceptHierarchy != null) {
		AtomicConcept concept = H((OWLClass) classExpression);
		HierarchyNode<AtomicConcept> node = m_atomicConceptHierarchy
				.getNodeForElement(concept);
		return node != m_atomicConceptHierarchy.getBottomNode();
	} else {
		OWLDataFactory factory = getDataFactory();
		OWLIndividual freshIndividual = factory
				.getOWLAnonymousIndividual("fresh-individual");
		OWLClassAssertionAxiom assertClassExpression = factory
				.getOWLClassAssertionAxiom(classExpression, freshIndividual);
		Tableau tableau = getTableau(assertClassExpression);
		return tableau.isSatisfiable(true, null, null, null, null, null,
				ReasoningTaskDescription
						.isConceptSatisfiable(classExpression));
	}
}
 
開發者ID:robertoyus,項目名稱:HermiT-android,代碼行數:23,代碼來源:Reasoner.java

示例2: isReflexive

import org.semanticweb.owlapi.model.OWLDataFactory; //導入方法依賴的package包/類
protected boolean isReflexive(OWLObjectPropertyExpression propertyExpression) {
	checkPreConditions(propertyExpression);
	if (!m_isConsistent)
		return true;
	OWLDataFactory factory = getDataFactory();
	OWLClass pseudoNominal = factory.getOWLClass(IRI
			.create("internal:pseudo-nominal"));
	OWLClassExpression allNotPseudoNominal = factory
			.getOWLObjectAllValuesFrom(propertyExpression,
					pseudoNominal.getObjectComplementOf());
	OWLIndividual freshIndividual = factory
			.getOWLAnonymousIndividual("fresh-individual");
	OWLAxiom pseudoNominalAssertion = factory.getOWLClassAssertionAxiom(
			pseudoNominal, freshIndividual);
	OWLAxiom allNotPseudoNominalAssertion = factory
			.getOWLClassAssertionAxiom(allNotPseudoNominal, freshIndividual);
	Tableau tableau = getTableau(pseudoNominalAssertion,
			allNotPseudoNominalAssertion);
	boolean result = tableau.isSatisfiable(true, null, null, null, null,
			null, new ReasoningTaskDescription(true, "symmetry of {0}",
					H(propertyExpression)));
	tableau.clearAdditionalDLOntology();
	return !result;
}
 
開發者ID:robertoyus,項目名稱:HermiT-android,代碼行數:25,代碼來源:Reasoner.java

示例3: testUnsatifiabilityDueToClashInABoxAssertions

import org.semanticweb.owlapi.model.OWLDataFactory; //導入方法依賴的package包/類
/**
   * Atomic clash
   */
  public void testUnsatifiabilityDueToClashInABoxAssertions() {
  	OWLDataFactory factory = OWLManager.getOWLDataFactory();
  	OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
  	
  	OWLClassExpression expr1 = factory.getOWLClass(IRI.create(String.format("%s#%s", PREFIX, "A")));
  	OWLClassExpression expr2 = factory.getOWLObjectComplementOf(expr1);
  	OWLNamedIndividual indiv = factory.getOWLNamedIndividual(IRI.create(String.format("%s#%s", PREFIX, "a")));
  	
  	OWLIndividualAxiom fact1 = factory.getOWLClassAssertionAxiom(expr1, indiv);
  	OWLIndividualAxiom fact2 = factory.getOWLClassAssertionAxiom(expr2, indiv);
  	
  	try {
	OWLOntology ontology = manager.createOntology();
	manager.addAxiom(ontology, fact1);
	manager.addAxiom(ontology, fact2);
	
	Wolpertinger wolpertinger = new Wolpertinger(ontology);
	
	assertFalse(wolpertinger.isConsistent());
} catch (OWLOntologyCreationException e) {
	e.printStackTrace();
	fail();
}
  }
 
開發者ID:wolpertinger-reasoner,項目名稱:Wolpertinger,代碼行數:28,代碼來源:WolpertingerTest.java

示例4: visit

import org.semanticweb.owlapi.model.OWLDataFactory; //導入方法依賴的package包/類
public Boolean visit(OWLDatatypeDefinitionAxiom axiom) {
    reasoner.throwInconsistentOntologyExceptionIfNecessary();
    if (!reasoner.isConsistent())
        return true;
    if (reasoner.m_dlOntology.hasDatatypes()) {
        OWLDataFactory factory=reasoner.getDataFactory();
        OWLIndividual freshIndividual=factory.getOWLAnonymousIndividual("fresh-individual");
        OWLDataProperty freshDataProperty=factory.getOWLDataProperty(IRI.create("fresh-data-property"));
        OWLDataRange dataRange=axiom.getDataRange();
        OWLDatatype dt=axiom.getDatatype();
        OWLDataIntersectionOf dr1=factory.getOWLDataIntersectionOf(factory.getOWLDataComplementOf(dataRange),dt);
        OWLDataIntersectionOf dr2=factory.getOWLDataIntersectionOf(factory.getOWLDataComplementOf(dt),dataRange);
        OWLDataUnionOf union=factory.getOWLDataUnionOf(dr1,dr2);
        OWLClassExpression c=factory.getOWLDataSomeValuesFrom(freshDataProperty,union);
        OWLClassAssertionAxiom ax=factory.getOWLClassAssertionAxiom(c,freshIndividual);
        Tableau tableau=reasoner.getTableau(ax);
        return !tableau.isSatisfiable(true,true,null,null,null,null,null,ReasoningTaskDescription.isAxiomEntailed(axiom));
    }
    else
        return false;
}
 
開發者ID:evalincius,項目名稱:Hermit_1.3.8_android,代碼行數:22,代碼來源:EntailmentChecker.java

示例5: testUnsatisfiabilityDuetoSimpleSubsumptionViolation

import org.semanticweb.owlapi.model.OWLDataFactory; //導入方法依賴的package包/類
public void testUnsatisfiabilityDuetoSimpleSubsumptionViolation() {
  	OWLDataFactory factory = OWLManager.getOWLDataFactory();
  	OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
  	
  	OWLClassExpression classA = factory.getOWLClass(IRI.create(String.format("%s#%s", PREFIX, "A")));
  	OWLClassExpression classB = factory.getOWLClass(IRI.create(String.format("%s#%s", PREFIX, "B")));
  	OWLClassExpression complClassB = factory.getOWLObjectComplementOf(classB);
  	
  	OWLNamedIndividual indiv = factory.getOWLNamedIndividual(IRI.create(String.format("%s#%s", PREFIX, "a")));
  	
  	OWLIndividualAxiom fact1 = factory.getOWLClassAssertionAxiom(classA, indiv);
  	OWLIndividualAxiom fact2 = factory.getOWLClassAssertionAxiom(complClassB, indiv);
  	
  	OWLSubClassOfAxiom subClOf = factory.getOWLSubClassOfAxiom(classA, classB);
  	
  	try {
	OWLOntology ontology = manager.createOntology();
	manager.addAxiom(ontology, fact1);
	manager.addAxiom(ontology, fact2);
	manager.addAxiom(ontology, subClOf);
	
	Wolpertinger wolpertinger = new Wolpertinger(ontology);
	
	assertFalse(wolpertinger.isConsistent());
} catch (OWLOntologyCreationException e) {
	e.printStackTrace();
	fail();
}
  }
 
開發者ID:wolpertinger-reasoner,項目名稱:Wolpertinger,代碼行數:30,代碼來源:WolpertingerTest.java

示例6: addType

import org.semanticweb.owlapi.model.OWLDataFactory; //導入方法依賴的package包/類
/**
 * Adds a ClassAssertion, where the class expression instantiated is an
 * ObjectSomeValuesFrom expression
 * 
 * Example: Individual: i Type: enabledBy some PRO_123
 *  
 * @param model
 * @param i
 * @param p
 * @param filler
 * @param metadata
 */
void addType(ModelContainer model,
		OWLIndividual i, 
		OWLObjectPropertyExpression p,
		OWLClassExpression filler,
		METADATA metadata) {
	if (LOG.isDebugEnabled()) {
		LOG.debug("Adding "+i+ " type "+p+" some "+filler);	
	}
	OWLDataFactory f = model.getOWLDataFactory();
	OWLObjectSomeValuesFrom c = f.getOWLObjectSomeValuesFrom(p, filler);
	OWLClassAssertionAxiom axiom = f.getOWLClassAssertionAxiom(c, i);
	addAxiom(model, axiom, metadata);
}
 
開發者ID:geneontology,項目名稱:minerva,代碼行數:26,代碼來源:CoreMolecularModelManager.java

示例7: removeType

import org.semanticweb.owlapi.model.OWLDataFactory; //導入方法依賴的package包/類
void removeType(ModelContainer model,
		OWLIndividual i, 
		OWLObjectPropertyExpression p,
		OWLClassExpression filler,
		METADATA metadata) {
	OWLDataFactory f = model.getOWLDataFactory();
	OWLClassAssertionAxiom axiom = f.getOWLClassAssertionAxiom(f.getOWLObjectSomeValuesFrom(p, filler), i);
	removeAxiom(model, axiom, metadata);
}
 
開發者ID:geneontology,項目名稱:minerva,代碼行數:10,代碼來源:CoreMolecularModelManager.java

示例8: addPABoxConstraints

import org.semanticweb.owlapi.model.OWLDataFactory; //導入方法依賴的package包/類
protected void addPABoxConstraints(OWLOntology ontology, PABox pabox, KnowledgeBase kb,
										OWLOntologyManager manager, OWLDataFactory  factory) {
	
	ConceptConverter converter = new ConceptConverter(kb, factory);
	
	for (Map.Entry<ATermAppl, Set<ConditionalConstraint>> entry : pabox.getConstraintsMap().entrySet()) {
		
		for (ConditionalConstraint cc : entry.getValue()) {

			OWLAnnotationProperty annProp = factory.getOWLAnnotationProperty( IRI.create( Constants.CERTAINTY_ANNOTATION_URI ));
			OWLAnnotationValue annValue = factory.getOWLStringLiteral( cc.getLowerBound() + ";" + cc.getUpperBound() );
			OWLAnnotation annotation = factory.getOWLAnnotation( annProp, annValue );	
			OWLIndividual indiv = factory.getOWLNamedIndividual( IRI.create( entry.getKey().getName()) );
			OWLClassExpression clsCn = (OWLClassExpression)converter.convert( cc.getConclusion() );
			OWLAxiom axiom = factory.getOWLClassAssertionAxiom( clsCn, indiv, Collections.singleton( annotation ) );
			
			try {
				
				manager.applyChange( new AddAxiom(ontology, axiom) );
				
			} catch( OWLOntologyChangeException e ) {
				
				e.printStackTrace();
			}
		}
	}
}
 
開發者ID:klinovp,項目名稱:pronto,代碼行數:28,代碼來源:PKBXMLSerializer.java

示例9: hasType

import org.semanticweb.owlapi.model.OWLDataFactory; //導入方法依賴的package包/類
public boolean hasType(OWLNamedIndividual namedIndividual,
		OWLClassExpression type, boolean direct) {
	checkPreConditions(namedIndividual, type);
	if (!m_isConsistent)
		return true;
	if (!isDefined(namedIndividual))
		return getEquivalentClasses(type).contains(
				m_rootOntology.getOWLOntologyManager().getOWLDataFactory()
						.getOWLThing());
	else {
		if (type instanceof OWLClass) {
			if (direct)
				classifyClasses();
			initialiseClassInstanceManager();
			if (direct)
				m_instanceManager
						.setToClassifiedConceptHierarchy(m_atomicConceptHierarchy);
			return m_instanceManager.hasType(H(namedIndividual),
					H((OWLClass) type), direct);
		} else {
			OWLDataFactory factory = getDataFactory();
			OWLAxiom negatedAssertionAxiom = factory
					.getOWLClassAssertionAxiom(
							type.getObjectComplementOf(), namedIndividual);
			Tableau tableau = getTableau(negatedAssertionAxiom);
			boolean result = tableau.isSatisfiable(true, true, null, null,
					null, null, null, ReasoningTaskDescription
							.isInstanceOf(namedIndividual, type));
			tableau.clearAdditionalDLOntology();
			return !result;
		}
	}
}
 
開發者ID:evalincius,項目名稱:Hermit_1.3.8_android,代碼行數:34,代碼來源:Reasoner.java

示例10: isSymmetric

import org.semanticweb.owlapi.model.OWLDataFactory; //導入方法依賴的package包/類
protected boolean isSymmetric(OWLObjectPropertyExpression propertyExpression) {
	checkPreConditions(propertyExpression);
	if (!m_isConsistent
			|| propertyExpression.getNamedProperty()
					.isOWLTopObjectProperty())
		return true;
	OWLDataFactory factory = getDataFactory();
	OWLClass pseudoNominal = factory.getOWLClass(IRI
			.create("internal:pseudo-nominal"));
	OWLClassExpression allNotPseudoNominal = factory
			.getOWLObjectAllValuesFrom(propertyExpression,
					pseudoNominal.getObjectComplementOf());
	OWLIndividual freshIndividualA = factory
			.getOWLAnonymousIndividual("fresh-individual-A");
	OWLIndividual freshIndividualB = factory
			.getOWLAnonymousIndividual("fresh-individual-B");
	OWLAxiom assertion1 = factory.getOWLObjectPropertyAssertionAxiom(
			propertyExpression, freshIndividualA, freshIndividualB);
	OWLAxiom assertion2 = factory.getOWLClassAssertionAxiom(
			allNotPseudoNominal, freshIndividualB);
	OWLAxiom assertion3 = factory.getOWLClassAssertionAxiom(pseudoNominal,
			freshIndividualA);
	Tableau tableau = getTableau(assertion1, assertion2, assertion3);
	boolean result = tableau.isSatisfiable(true, null, null, null, null,
			null, new ReasoningTaskDescription(true, "symmetry of {0}",
					propertyExpression));
	tableau.clearAdditionalDLOntology();
	return !result;
}
 
開發者ID:robertoyus,項目名稱:HermiT-android,代碼行數:30,代碼來源:Reasoner.java

示例11: testUnsatisfiabilityDoToFixedDomain1

import org.semanticweb.owlapi.model.OWLDataFactory; //導入方法依賴的package包/類
/**
   * Smth like
   *    A subClassOf r min 5 B
   *  But we have only a domain with 4 elements ...
   */
  public void testUnsatisfiabilityDoToFixedDomain1() {
  	OWLDataFactory factory = OWLManager.getOWLDataFactory();
  	OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
  	
  	OWLClassExpression classA = factory.getOWLClass(IRI.create(String.format("%s#%s", PREFIX, "A")));
  	OWLClassExpression classB = factory.getOWLClass(IRI.create(String.format("%s#%s", PREFIX, "B")));
  	OWLObjectPropertyExpression roleR = factory.getOWLObjectProperty(IRI.create(String.format("%s#%s", PREFIX, "r")));
  	
  	OWLNamedIndividual indA = factory.getOWLNamedIndividual(IRI.create(String.format("%s#%s", PREFIX, "a")));
  	OWLNamedIndividual indB = factory.getOWLNamedIndividual(IRI.create(String.format("%s#%s", PREFIX, "b")));
  	OWLNamedIndividual indC = factory.getOWLNamedIndividual(IRI.create(String.format("%s#%s", PREFIX, "c")));
  	OWLNamedIndividual indD = factory.getOWLNamedIndividual(IRI.create(String.format("%s#%s", PREFIX, "d")));

  	OWLIndividualAxiom fact1 = factory.getOWLClassAssertionAxiom(classA, indA);
  	OWLIndividualAxiom fact2 = factory.getOWLClassAssertionAxiom(classA, indB);
  	OWLIndividualAxiom fact3 = factory.getOWLClassAssertionAxiom(classA, indC);
  	OWLIndividualAxiom fact4 = factory.getOWLClassAssertionAxiom(classA, indD);
  	
  	OWLObjectMinCardinality exprRmin5B = factory.getOWLObjectMinCardinality(5, roleR, classB);
  	OWLSubClassOfAxiom axmAsubRsomeB = factory.getOWLSubClassOfAxiom(classA, exprRmin5B);
  	
  	try {
	OWLOntology ontology = manager.createOntology();
	manager.addAxiom(ontology, fact1);
	manager.addAxiom(ontology, fact2);
	manager.addAxiom(ontology, fact3);
	manager.addAxiom(ontology, fact4);
	manager.addAxiom(ontology, axmAsubRsomeB);
	
	Wolpertinger wolpertinger = new Wolpertinger(ontology);
	
	assertFalse(wolpertinger.isConsistent());
} catch (OWLOntologyCreationException e) {
	e.printStackTrace();
	fail();
}
  }
 
開發者ID:wolpertinger-reasoner,項目名稱:Wolpertinger,代碼行數:43,代碼來源:WolpertingerTest.java

示例12: isRoleInstance

import org.semanticweb.owlapi.model.OWLDataFactory; //導入方法依賴的package包/類
protected boolean isRoleInstance(Role role, Individual individual1, Individual individual2) {
    OWLDataFactory factory=m_reasoner.getDataFactory();
    AtomicRole atomicRole;
    if (role instanceof InverseRole) {
        Individual tmp=individual1;
        individual1=individual2;
        individual2=tmp;
        atomicRole=((InverseRole)role).getInverseOf();
    }
    else
        atomicRole=(AtomicRole)role;
    OWLObjectProperty property=factory.getOWLObjectProperty(IRI.create(atomicRole.getIRI()));
    OWLNamedIndividual namedIndividual1=factory.getOWLNamedIndividual(IRI.create(individual1.getIRI()));
    OWLNamedIndividual namedIndividual2=factory.getOWLNamedIndividual(IRI.create(individual2.getIRI()));
    OWLClass pseudoNominal=factory.getOWLClass(IRI.create("internal:pseudo-nominal"));
    OWLClassExpression allNotPseudoNominal=factory.getOWLObjectAllValuesFrom(property,pseudoNominal.getObjectComplementOf());
    OWLAxiom allNotPseudoNominalAssertion=factory.getOWLClassAssertionAxiom(allNotPseudoNominal,namedIndividual1);
    OWLAxiom pseudoNominalAssertion=factory.getOWLClassAssertionAxiom(pseudoNominal,namedIndividual2);
    Tableau tableau=m_reasoner.getTableau(allNotPseudoNominalAssertion,pseudoNominalAssertion);
    boolean result=!tableau.isSatisfiable(true,true,null,null,null,null,null,new ReasoningTaskDescription(true,"is {0} connected to {1} via {2}",individual1,individual2,atomicRole));
    if (m_tableauMonitor!=null) {
        if (result)
            m_tableauMonitor.possibleInstanceIsInstance();
        else 
            m_tableauMonitor.possibleInstanceIsNotInstance();
    }
    return result;
}
 
開發者ID:robertoyus,項目名稱:HermiT-android,代碼行數:29,代碼來源:InstanceManager.java

示例13: isTransitive

import org.semanticweb.owlapi.model.OWLDataFactory; //導入方法依賴的package包/類
protected boolean isTransitive(
		OWLObjectPropertyExpression propertyExpression) {
	checkPreConditions(propertyExpression);
	if (!m_isConsistent)
		return true;
	OWLDataFactory factory = getDataFactory();
	OWLClass pseudoNominal = factory.getOWLClass(IRI
			.create("internal:pseudo-nominal"));
	OWLClassExpression allNotPseudoNominal = factory
			.getOWLObjectAllValuesFrom(propertyExpression,
					pseudoNominal.getObjectComplementOf());
	OWLIndividual freshIndividualA = factory
			.getOWLAnonymousIndividual("fresh-individual-A");
	OWLIndividual freshIndividualB = factory
			.getOWLAnonymousIndividual("fresh-individual-B");
	OWLIndividual freshIndividualC = factory
			.getOWLAnonymousIndividual("fresh-individual-C");
	OWLAxiom assertion1 = factory.getOWLObjectPropertyAssertionAxiom(
			propertyExpression, freshIndividualA, freshIndividualB);
	OWLAxiom assertion2 = factory.getOWLObjectPropertyAssertionAxiom(
			propertyExpression, freshIndividualB, freshIndividualC);
	OWLAxiom assertion3 = factory.getOWLClassAssertionAxiom(
			allNotPseudoNominal, freshIndividualA);
	OWLAxiom assertion4 = factory.getOWLClassAssertionAxiom(pseudoNominal,
			freshIndividualC);
	Tableau tableau = getTableau(assertion1, assertion2, assertion3,
			assertion4);
	boolean result = tableau.isSatisfiable(true, null, null, null, null,
			null, new ReasoningTaskDescription(true, "transitivity of {0}",
					H(propertyExpression)));
	tableau.clearAdditionalDLOntology();
	return !result;
}
 
開發者ID:evalincius,項目名稱:Hermit_1.3.8_android,代碼行數:34,代碼來源:Reasoner.java

示例14: isSubObjectPropertyExpressionOf

import org.semanticweb.owlapi.model.OWLDataFactory; //導入方法依賴的package包/類
protected boolean isSubObjectPropertyExpressionOf(
		List<OWLObjectPropertyExpression> subPropertyChain,
		OWLObjectPropertyExpression superObjectPropertyExpression) {
	OWLObject[] objects = new OWLObject[subPropertyChain.size() + 1];
	for (int i = 0; i < subPropertyChain.size(); i++)
		objects[i] = subPropertyChain.get(i);
	objects[subPropertyChain.size()] = superObjectPropertyExpression;
	checkPreConditions(objects);
	if (!m_isConsistent
			|| superObjectPropertyExpression.getNamedProperty()
					.isOWLTopObjectProperty())
		return true;
	else {
		OWLDataFactory factory = getDataFactory();
		OWLClass pseudoNominal = factory.getOWLClass(IRI
				.create("internal:pseudo-nominal"));
		OWLClassExpression allSuperNotPseudoNominal = factory
				.getOWLObjectAllValuesFrom(superObjectPropertyExpression,
						pseudoNominal.getObjectComplementOf());
		OWLAxiom[] additionalAxioms = new OWLAxiom[subPropertyChain.size() + 2];
		int axiomIndex = 0;
		for (OWLObjectPropertyExpression subObjectPropertyExpression : subPropertyChain) {
			OWLIndividual first = factory
					.getOWLAnonymousIndividual("fresh-individual-"
							+ axiomIndex);
			OWLIndividual second = factory
					.getOWLAnonymousIndividual("fresh-individual-"
							+ (axiomIndex + 1));
			additionalAxioms[axiomIndex++] = factory
					.getOWLObjectPropertyAssertionAxiom(
							subObjectPropertyExpression, first, second);
		}
		OWLIndividual freshIndividual0 = factory
				.getOWLAnonymousIndividual("fresh-individual-0");
		OWLIndividual freshIndividualN = factory
				.getOWLAnonymousIndividual("fresh-individual-"
						+ subPropertyChain.size());
		additionalAxioms[axiomIndex++] = factory.getOWLClassAssertionAxiom(
				pseudoNominal, freshIndividualN);
		additionalAxioms[axiomIndex++] = factory.getOWLClassAssertionAxiom(
				allSuperNotPseudoNominal, freshIndividual0);
		Tableau tableau = getTableau(additionalAxioms);
		return !tableau.isSatisfiable(true, null, null, null, null, null,
				new ReasoningTaskDescription(true,
						"subproperty chain subsumption"));
	}
}
 
開發者ID:robertoyus,項目名稱:HermiT-android,代碼行數:48,代碼來源:Reasoner.java

示例15: createSimpleGraphColoring

import org.semanticweb.owlapi.model.OWLDataFactory; //導入方法依賴的package包/類
private OWLOntology createSimpleGraphColoring() {
  	OWLOntology ontoColoring = null;
  	OWLDataFactory factory = OWLManager.getOWLDataFactory();
  	OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
  	
  	OWLObjectPropertyExpression edgeProp = factory.getOWLObjectProperty(IRI.create(String.format("%s#%s", PREFIX, "edge")));
  	OWLClassExpression classNode = factory.getOWLClass(IRI.create(String.format("%s#%s", PREFIX, "Node")));
  	OWLClassExpression classBlue = factory.getOWLClass(IRI.create(String.format("%s#%s", PREFIX, "Blue")));
  	OWLClassExpression classRed = factory.getOWLClass(IRI.create(String.format("%s#%s", PREFIX, "Red")));
  	OWLClassExpression classGreen = factory.getOWLClass(IRI.create(String.format("%s#%s", PREFIX, "Green")));
  	
  	OWLNamedIndividual indNode1 = factory.getOWLNamedIndividual(IRI.create(String.format("%s#%s", PREFIX, "node1")));
  	OWLNamedIndividual indNode2 = factory.getOWLNamedIndividual(IRI.create(String.format("%s#%s", PREFIX, "node2")));
  	OWLNamedIndividual indNode3 = factory.getOWLNamedIndividual(IRI.create(String.format("%s#%s", PREFIX, "node3")));
  	OWLNamedIndividual indNode4 = factory.getOWLNamedIndividual(IRI.create(String.format("%s#%s", PREFIX, "node4")));
  	
  	// now the facts
  	// nodes
  	OWLIndividualAxiom axmNodeInst4 =factory.getOWLClassAssertionAxiom(classNode, indNode4);
  	OWLIndividualAxiom axmNodeInst3 =factory.getOWLClassAssertionAxiom(classNode, indNode3);
  	OWLIndividualAxiom axmNodeInst2 =factory.getOWLClassAssertionAxiom(classNode, indNode2);
  	OWLIndividualAxiom axmNodeInst1 =factory.getOWLClassAssertionAxiom(classNode, indNode1);
  	
  	// 1
  	// | \
  	// |  3 - 4
  	// | /
  	// 2
  	//
  	OWLIndividualAxiom axmEdge12 = factory.getOWLObjectPropertyAssertionAxiom(edgeProp, indNode1, indNode2);
  	OWLIndividualAxiom axmEdge13 = factory.getOWLObjectPropertyAssertionAxiom(edgeProp, indNode1, indNode3);
  	OWLIndividualAxiom axmEdge23 = factory.getOWLObjectPropertyAssertionAxiom(edgeProp, indNode2, indNode3);
  	OWLIndividualAxiom axmEdge34 = factory.getOWLObjectPropertyAssertionAxiom(edgeProp, indNode3, indNode4);
  	
  	// symmetry of edge property
  	OWLObjectPropertyAxiom axmEdgeSym =  factory.getOWLSymmetricObjectPropertyAxiom(edgeProp);
  	
  	// axioms
  	OWLObjectUnionOf exprColorUnion = factory.getOWLObjectUnionOf(classBlue, classRed, classGreen);
  	OWLSubClassOfAxiom axmNodeColorings = factory.getOWLSubClassOfAxiom(classNode, exprColorUnion);
  	
  	// coloring constraints
  	OWLSubClassOfAxiom axmRedConstraint = factory.getOWLSubClassOfAxiom(classRed, factory.getOWLObjectAllValuesFrom(edgeProp, factory.getOWLObjectUnionOf(classGreen, classBlue)));
  	OWLSubClassOfAxiom axmBlueConstraint = factory.getOWLSubClassOfAxiom(classBlue, factory.getOWLObjectAllValuesFrom(edgeProp, factory.getOWLObjectUnionOf(classGreen, classRed)));
  	OWLSubClassOfAxiom axmGreenConstraint = factory.getOWLSubClassOfAxiom(classGreen, factory.getOWLObjectAllValuesFrom(edgeProp, factory.getOWLObjectUnionOf(classRed, classBlue)));
  	OWLDisjointClassesAxiom axmDisColors = factory.getOWLDisjointClassesAxiom(classRed, classBlue, classGreen);
  	
  	try {
	ontoColoring = manager.createOntology(); 
	
	manager.addAxiom(ontoColoring, axmNodeInst1);
	manager.addAxiom(ontoColoring, axmNodeInst2);
	manager.addAxiom(ontoColoring, axmNodeInst3);
	manager.addAxiom(ontoColoring, axmNodeInst4);
	
	manager.addAxiom(ontoColoring, axmEdge12);
	manager.addAxiom(ontoColoring, axmEdge13);
	manager.addAxiom(ontoColoring, axmEdge23);
	manager.addAxiom(ontoColoring, axmEdge34);
	
	manager.addAxiom(ontoColoring, axmEdgeSym);
	manager.addAxiom(ontoColoring, axmNodeColorings);
	manager.addAxiom(ontoColoring, axmRedConstraint);
	manager.addAxiom(ontoColoring, axmBlueConstraint);
	manager.addAxiom(ontoColoring, axmGreenConstraint);
	manager.addAxiom(ontoColoring, axmDisColors);
} catch (OWLOntologyCreationException e) {
	e.printStackTrace();
}
  	
  	return ontoColoring;
  }
 
開發者ID:wolpertinger-reasoner,項目名稱:Wolpertinger,代碼行數:73,代碼來源:WolpertingerTest.java


注:本文中的org.semanticweb.owlapi.model.OWLDataFactory.getOWLClassAssertionAxiom方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。