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


Java OWLDataFactory.getOWLClass方法代碼示例

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


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

示例1: testOWLClassHashCode

import org.semanticweb.owlapi.model.OWLDataFactory; //導入方法依賴的package包/類
/**
 * Test that two {@code OWLClass}es that are equal have a same hashcode, 
 * because the OWLGraphEdge bug get me paranoid. 
 */
@Test
public void testOWLClassHashCode()
{
	 OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
	 OWLDataFactory factory = manager.getOWLDataFactory(); 
	 IRI iri = IRI.create("http://www.foo.org/#A");
	 OWLClass class1 = factory.getOWLClass(iri);
	 //get the class by another way, even if if I suspect the two references 
	 //will point to the same object
	 PrefixManager pm = new DefaultPrefixManager("http://www.foo.org/#"); 
	 OWLClass class2 = factory.getOWLClass(":A", pm);
	 
	 assertTrue("The two references point to different OWLClass objects", 
			 class1 == class2);
	 //then of course the hashcodes will be the same...
	 assertTrue("Two OWLClasses are equal but have different hashcode", 
			 class1.equals(class2) && class1.hashCode() == class2.hashCode());
}
 
開發者ID:owlcollab,項目名稱:owltools,代碼行數:23,代碼來源:OWLGraphManipulatorTest.java

示例2: addAutoGeneratedClassNames

import org.semanticweb.owlapi.model.OWLDataFactory; //導入方法依賴的package包/類
private void addAutoGeneratedClassNames(OWLOntologyManager manager,
										OWLOntology ontology,
										Map<String, OWLClassExpression> nameMap) {
	
	OWLDataFactory factory = manager.getOWLDataFactory();
	List<OWLOntologyChange> changes = new ArrayList<OWLOntologyChange>();
	
	for (Map.Entry<String, OWLClassExpression> entry : nameMap.entrySet()) {
		
		OWLClass subClass = factory.getOWLClass( IRI.create(entry.getKey()) );
		OWLAxiom declAxiom = factory.getOWLEquivalentClassesAxiom( subClass, entry.getValue() );
		
		changes.addAll( manager.addAxiom( ontology, declAxiom ) );
	}
	
	manager.applyChanges( changes );
}
 
開發者ID:klinovp,項目名稱:pronto,代碼行數:18,代碼來源:KBEmbeddedLoader.java

示例3: addElementToAttributeAssociationsFromFile

import org.semanticweb.owlapi.model.OWLDataFactory; //導入方法依賴的package包/類
public static void addElementToAttributeAssociationsFromFile(OWLOntology ont, File file) throws IOException {
	OWLOntologyManager m = OWLManager.createOWLOntologyManager();
	OWLDataFactory df = m.getOWLDataFactory();
	List<String> lines = FileUtils.readLines(file);
	for (String line : lines) {
		if (line.startsWith("#"))
			continue;
		String[] colVals = line.split("\t");
		if (colVals.length != 2) {
			throw new IOException("Incorrect number of value: "+line);
		}
		OWLNamedIndividual i = df.getOWLNamedIndividual(getIRIById(colVals[0]));
		OWLClass c = df.getOWLClass(getIRIById(colVals[1]));
		m.addAxiom(ont, df.getOWLClassAssertionAxiom(c, i));
	}
}
 
開發者ID:owlcollab,項目名稱:owltools,代碼行數:17,代碼來源:OwlSimUtil.java

示例4: translateResultsToOWLAxioms

import org.semanticweb.owlapi.model.OWLDataFactory; //導入方法依賴的package包/類
/**
 * adds additional axioms specific to this method.
 * Creates a named LCS class equivalent to the generated expression
 * 
 * @param id
 * @param result
 * @param axioms
 */
@Override
protected void translateResultsToOWLAxioms(String id, OWLNamedIndividual result, Set<OWLAxiom> axioms) {
	OWLDataFactory df = graph.getDataFactory();
	
	// declare a named class for the LCS and make this equivalent to the anonymous expression
	OWLClass namedLCS = df.getOWLClass(IRI.create(id+"_LCS"));
	axioms.add(df.getOWLAnnotationAssertionAxiom(df.getOWLAnnotationProperty(OWLRDFVocabulary.RDFS_LABEL.getIRI()),
			namedLCS.getIRI(), 
			df.getOWLLiteral("LCS of "+simEngine.label(a)+" and "+simEngine.label(b))));
	axioms.add(df.getOWLEquivalentClassesAxiom(namedLCS, lcs));

	// link the similarity object to the named LCS
	OWLAnnotationProperty lcsp = df.getOWLAnnotationProperty(annotationIRI("has_least_common_subsumer"));
	axioms.add(df.getOWLAnnotationAssertionAxiom(lcsp, result.getIRI(), namedLCS.getIRI()));
}
 
開發者ID:owlcollab,項目名稱:owltools,代碼行數:24,代碼來源:DescriptionTreeSimilarity.java

示例5: prepare

import org.semanticweb.owlapi.model.OWLDataFactory; //導入方法依賴的package包/類
@Override
void prepare() {
	final OWLDataFactory factory = new OWLDataFactoryImpl();
	A = factory.getOWLClass(IRI.create("A"));
	B = factory.getOWLClass(IRI.create("B"));
	OWLObjectProperty R = factory.getOWLObjectProperty(IRI.create("R"));
	OWLObjectProperty S = factory.getOWLObjectProperty(IRI.create("S"));
	OWLAxiom axExSsomeAsubB = factory.getOWLSubClassOfAxiom(
			factory.getOWLObjectSomeValuesFrom(S, A), B);
	OWLAxiom axReflR = factory.getOWLReflexiveObjectPropertyAxiom(R);
	axRsubS = factory.getOWLSubObjectPropertyOfAxiom(R, S);
	// from these three axioms it should follow A subclass B
	ontologyManager = TestOWLManager.createOWLOntologyManager();
	try {
		ont = ontologyManager.createOntology(new HashSet<OWLAxiom>(Arrays
				.asList(axExSsomeAsubB, axReflR, axRsubS)));
	} catch (OWLOntologyCreationException e) {
		fail(e.toString());
	}
}
 
開發者ID:liveontologies,項目名稱:elk-reasoner,代碼行數:21,代碼來源:RoleAxiomOWLAPILowLevelIncrementalClassTest.java

示例6: testSpecies

import org.semanticweb.owlapi.model.OWLDataFactory; //導入方法依賴的package包/類
private void testSpecies(OWLOntology ontology) {
	IRI iri = IRI.create("http://purl.obolibrary.org/obo/NCBITaxon_species");
	OWLDataFactory df = ontology.getOWLOntologyManager().
		getOWLDataFactory();
	OWLClass taxon = df.getOWLClass(iri);
	assertTrue("Species class in signature",
		ontology.containsClassInSignature(iri));
	
	// Check axioms
	Set<OWLClassAxiom> axioms = ontology.getAxioms(taxon, Imports.EXCLUDED);
	assertEquals("Count class axioms", 1, axioms.size());
	assertEquals("SubClassOf(<http://purl.obolibrary.org/obo/NCBITaxon_species> <http://purl.obolibrary.org/obo/NCBITaxon#_taxonomic_rank>)", axioms.toArray()[0].toString());

	// Check annotations
	List<String> values = new ArrayList<String>();
	values.add("AnnotationAssertion(<http://www.geneontology.org/formats/oboInOwl#hasOBONamespace> <http://purl.obolibrary.org/obo/NCBITaxon_species> \"ncbi_taxonomy\"^^xsd:string)");
	values.add("AnnotationAssertion(rdfs:label <http://purl.obolibrary.org/obo/NCBITaxon_species> \"species\"^^xsd:string)");

	Set<OWLAnnotationAssertionAxiom> annotations = 
		ontology.getAnnotationAssertionAxioms(iri);
	assertEquals("Count annotations for Species", 2, annotations.size());

	checkAnnotations(annotations, values);
}
 
開發者ID:owlcollab,項目名稱:owltools,代碼行數:25,代碼來源:NCBI2OWLTest.java

示例7: computeAttributeSetSimilarityStats

import org.semanticweb.owlapi.model.OWLDataFactory; //導入方法依賴的package包/類
public SummaryStatistics computeAttributeSetSimilarityStats(Set<OWLClass> atts)  {

		SummaryStatistics statsPerAttSet = new SummaryStatistics();
		//		Set<OWLClass> allClasses = getSourceOntology().getClassesInSignature(true);
		OWLDataFactory g = getSourceOntology().getOWLOntologyManager().getOWLDataFactory();

		for (OWLClass c : atts) {
			Double ic;
			try {
				ic = this.getInformationContentForAttribute(c);
				if (ic == null) { 
					//If a class hasn't been annotated in the loaded corpus, we will
					//assume that it is very rare, and assign MaxIC
					if (g.getOWLClass(c.getIRI()) != null) {
						ic = this.getSummaryStatistics().max.getMax();
					} else {
						throw new UnknownOWLClassException(c); }
				}
				if (ic.isInfinite() || ic.isNaN()) {
					//If a class hasn't been annotated in the loaded corpus, we will
					//assume that it is very rare, and assign MaxIC
					//a different option would be to skip adding this value, 
					//but i'm not sure that's wise
					ic = this.getSummaryStatistics().max.getMax();
				}
				//LOG.info("IC for "+c.toString()+"is: "+ic);
				statsPerAttSet.addValue(ic);	

			} catch (UnknownOWLClassException e) {
				//This is an extra catch here, but really it should be caught upstream.
				LOG.info("Unknown class "+c.toStringID()+" submitted for summary stats. Removed from calculation.");
				continue;
			}
		}
		return statsPerAttSet;
	}
 
開發者ID:owlcollab,項目名稱:owltools,代碼行數:37,代碼來源:AbstractOwlSim.java

示例8: prepare

import org.semanticweb.owlapi.model.OWLDataFactory; //導入方法依賴的package包/類
@Override
void prepare() {
	final OWLDataFactory factory = new OWLDataFactoryImpl();
	A = factory.getOWLClass(IRI.create("A"));
	B = factory.getOWLClass(IRI.create("B"));
	axAsubB = factory.getOWLSubClassOfAxiom(A, B);
	axBsubA = factory.getOWLSubClassOfAxiom(B, A);
	ontologyManager = TestOWLManager.createOWLOntologyManager();
	try {
		ont = ontologyManager.createOntology(new HashSet<OWLAxiom>(Arrays
				.asList(axAsubB, axBsubA)));
	} catch (OWLOntologyCreationException e) {
		fail(e.toString());
	}
}
 
開發者ID:liveontologies,項目名稱:elk-reasoner,代碼行數:16,代碼來源:ConceptAxiomOWLAPILowLevelIncrementalClassTest.java

示例9: test1

import org.semanticweb.owlapi.model.OWLDataFactory; //導入方法依賴的package包/類
public void test1() throws Exception {
	OWLDataFactory df = NEO.getOWLOntologyManager().getOWLDataFactory();
	FindTaxonTool tool = new FindTaxonTool(curieHandler , df);
	OWLClass zfin1 = df.getOWLClass(IRI.create("http://purl.obolibrary.org/obo/ZFIN_ZDB-GENE-991124-7"));
	String taxon1 = tool.getEntityTaxon(zfin1 , NEO);
	assertNotNull(taxon1);
}
 
開發者ID:geneontology,項目名稱:minerva,代碼行數:8,代碼來源:FindTaxonToolTest.java

示例10: testIgnoreIgnoreOwlNothingInNewInferences

import org.semanticweb.owlapi.model.OWLDataFactory; //導入方法依賴的package包/類
/**
 * Test that the {@link InferenceBuilder} does not report the trivial fact
 * that OWL:Nothing is a subclass of of every class.
 * 
 * @throws Exception 
 */
@Test
public void testIgnoreIgnoreOwlNothingInNewInferences() throws Exception {
	// create a test ontology which declares owl:Nothing and one term
	
	OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
	
	OWLOntology ontology = manager.createOntology();
	OWLDataFactory factory = manager.getOWLDataFactory();
	
	// declare class
	
	OWLClass owlEntity = factory.getOWLClass(IRI.create("http://foo.bar/1"));
	manager.addAxiom(ontology, factory.getOWLDeclarationAxiom(owlEntity));
	
	// declare owl:Nothing
	manager.addAxiom(ontology, factory.getOWLDeclarationAxiom(factory.getOWLNothing()));
	
	OWLGraphWrapper graph = new OWLGraphWrapper(ontology);
	
	// check that the inference builder does not report a new inferred axiom
	InferenceBuilder builder = new InferenceBuilder(graph);
	try {
		List<OWLAxiom> inferences = builder.buildInferences();
		if (!inferences.isEmpty()) {
			fail("Do not expect any new inferences, but was: "+inferences);
		}
	}
	finally {
		builder.dispose();
	}
}
 
開發者ID:owlcollab,項目名稱:owltools,代碼行數:38,代碼來源:InferenceBuilderTest.java

示例11: 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:evalincius,項目名稱:Hermit_1.3.8_android,代碼行數:30,代碼來源:Reasoner.java

示例12: createTaxon

import org.semanticweb.owlapi.model.OWLDataFactory; //導入方法依賴的package包/類
/**
 * Create a class for an NCBI Taxonomy ID and add it to the ontology.
 *
 * @param ontology the current ontology
 * @param id the NCBI Taxonomy ID, will be expanded into an IRI of the
 *	form http://purl.obolibrary.org/obo/NCBITaxon_1
 * @return the new class
 */
public static OWLClass createTaxon(OWLOntology ontology, String id) {
	IRI iri = createNCBIIRI(id);
	OWLDataFactory dataFactory = ontology.getOWLOntologyManager().
		getOWLDataFactory();
	OWLClass taxon = dataFactory.getOWLClass(iri);
	declare(ontology, taxon);
	annotate(ontology, taxon, "oio:hasOBONamespace",
		"ncbi_taxonomy");
	return taxon;
}
 
開發者ID:owlcollab,項目名稱:owltools,代碼行數:19,代碼來源:NCBIConverter.java

示例13: translateResultsToOWLAxioms

import org.semanticweb.owlapi.model.OWLDataFactory; //導入方法依賴的package包/類
@Override
protected void translateResultsToOWLAxioms(String id, OWLNamedIndividual result, Set<OWLAxiom> axioms) {
	OWLDataFactory df = simEngine.getGraph().getDataFactory();
	
	// declare a named class for the LCS and make this equivalent to the anonymous expression
	OWLClass namedLCS = df.getOWLClass(IRI.create(id+"_LCS"));
	axioms.add(df.getOWLAnnotationAssertionAxiom(df.getOWLAnnotationProperty(OWLRDFVocabulary.RDFS_LABEL.getIRI()),
			namedLCS.getIRI(), 
			df.getOWLLiteral("LCS of "+simEngine.label(a)+" and "+simEngine.label(b))));
	axioms.add(df.getOWLEquivalentClassesAxiom(namedLCS, getLCS()));

	// link the similarity object to the named LCS
	OWLAnnotationProperty lcsp = df.getOWLAnnotationProperty(annotationIRI("has_least_common_subsumer"));
	axioms.add(df.getOWLAnnotationAssertionAxiom(lcsp, result.getIRI(), namedLCS.getIRI()));
}
 
開發者ID:owlcollab,項目名稱:owltools,代碼行數:16,代碼來源:ConjunctiveSetInformationContentRatioSimilarity.java

示例14: getAxiomsForReadingOffCompexProperties

import org.semanticweb.owlapi.model.OWLDataFactory; //導入方法依賴的package包/類
public OWLAxiom[] getAxiomsForReadingOffCompexProperties(OWLDataFactory factory, ReasonerProgressMonitor monitor, int completedSteps, int steps) {
    if (m_complexRoles.size()>0) {
        int noAdditionalAxioms=0;
        List<OWLAxiom> additionalAxioms=new ArrayList<OWLAxiom>();
        m_interruptFlag.startTask();
        try {
            for (;m_currentIndividualIndex<m_individuals.length && noAdditionalAxioms < thresholdForAdditionalAxioms;m_currentIndividualIndex++) {
                Individual ind=m_individuals[m_currentIndividualIndex];
                for (AtomicRole objectRole : m_complexRoles) {
                    completedSteps++;
                    if (monitor!=null)
                        monitor.reasonerTaskProgressChanged(completedSteps,steps);
                    OWLObjectProperty objectProperty=factory.getOWLObjectProperty(IRI.create(objectRole.getIRI()));
                    String indIRI=ind.getIRI();
                    OWLClass classForIndividual=factory.getOWLClass(IRI.create("internal:individual-concept#"+indIRI));
                    OWLAxiom axiom=factory.getOWLClassAssertionAxiom(classForIndividual,factory.getOWLNamedIndividual(IRI.create(indIRI)));
                    additionalAxioms.add(axiom); // A_a(a)
                    AtomicConcept conceptForRole=AtomicConcept.create("internal:individual-concept#"+objectRole.getIRI()+"#"+indIRI);
                    OWLClass classForRoleAndIndividual=factory.getOWLClass(IRI.create(conceptForRole.getIRI()));
                    axiom=factory.getOWLSubClassOfAxiom(classForIndividual,factory.getOWLObjectAllValuesFrom(objectProperty,classForRoleAndIndividual));
                    additionalAxioms.add(axiom); // A_a implies forall r.A_a^r
                    noAdditionalAxioms+=2;
                    m_interruptFlag.checkInterrupt();
                }
            }
        } finally {
            m_interruptFlag.endTask();
        }
        OWLAxiom[] additionalAxiomsArray=new OWLAxiom[additionalAxioms.size()];
        return additionalAxioms.toArray(additionalAxiomsArray);
    }
    else {
        m_currentIndividualIndex=m_individuals.length-1;
        return new OWLAxiom[0];
    }
}
 
開發者ID:robertoyus,項目名稱:HermiT-android,代碼行數:37,代碼來源:InstanceManager.java

示例15: getEntailment

import org.semanticweb.owlapi.model.OWLDataFactory; //導入方法依賴的package包/類
private static OWLAxiom getEntailment() {
	// Let's pick some class subsumption we want to explain
	OWLDataFactory factory = OWLManager.getOWLDataFactory();
	
	OWLClass subsumee = factory.getOWLClass(IRI.create("http://www.co-ode.org/ontologies/galen#LiquidFood"));
	OWLClass subsumer = factory.getOWLClass(IRI.create("http://www.co-ode.org/ontologies/galen#Food"));
	
	return factory.getOWLSubClassOfAxiom(subsumee, subsumer);
}
 
開發者ID:liveontologies,項目名稱:elk-reasoner,代碼行數:10,代碼來源:RetrievingProofsForEntailment.java


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