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


Java OWLDataFactory類代碼示例

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


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

示例1: createIndividualInternal

import org.semanticweb.owlapi.model.OWLDataFactory; //導入依賴的package包/類
private static Pair<OWLNamedIndividual, Set<OWLAxiom>> createIndividualInternal(IRI iri, OWLOntology abox, OWLClassExpression ce, Set<OWLAnnotation> annotations) {
	LOG.info("Generating individual for IRI: "+iri);
	OWLDataFactory f = abox.getOWLOntologyManager().getOWLDataFactory();
	OWLNamedIndividual i = f.getOWLNamedIndividual(iri);
	
	// create axioms
	Set<OWLAxiom> axioms = new HashSet<OWLAxiom>();
	// declaration
	axioms.add(f.getOWLDeclarationAxiom(i));
	// annotation assertions
	if(annotations != null) {
		for(OWLAnnotation annotation : annotations) {
			axioms.add(f.getOWLAnnotationAssertionAxiom(iri, annotation));
		}
	}
	
	if (ce != null) {
		OWLClassAssertionAxiom typeAxiom = createType(f, i, ce);
		if (typeAxiom != null) {
			axioms.add(typeAxiom);
		}
	}
	
	return Pair.of(i, axioms);
}
 
開發者ID:geneontology,項目名稱:minerva,代碼行數:26,代碼來源:CoreMolecularModelManager.java

示例2: 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

示例3: visit

import org.semanticweb.owlapi.model.OWLDataFactory; //導入依賴的package包/類
@Override
public OWLAxiom visit(RI3Axiom axiom) {
	Objects.requireNonNull(axiom);
	OWLObjectProperty owlLeftSubProperty = translator.getTranslationRepository()
			.getOWLObjectProperty(axiom.getLeftSubProperty());
	OWLObjectProperty owlRightSubProperty = translator.getTranslationRepository()
			.getOWLObjectProperty(axiom.getRightSubProperty());
	OWLObjectProperty owlSuperProperty = translator.getTranslationRepository()
			.getOWLObjectProperty(axiom.getSuperProperty());
	Set<OWLAnnotation> owlAnnotations = translateAnnotations(axiom.getAnnotations());
	OWLDataFactory dataFactory = ontology.getOWLOntologyManager().getOWLDataFactory();
	List<OWLObjectProperty> owlPropertyList = new ArrayList<>();
	owlPropertyList.add(owlLeftSubProperty);
	owlPropertyList.add(owlRightSubProperty);
	return dataFactory.getOWLSubPropertyChainOfAxiom(owlPropertyList, owlSuperProperty, owlAnnotations);
}
 
開發者ID:julianmendez,項目名稱:jcel,代碼行數:17,代碼來源:ReverseAxiomTranslator.java

示例4: getEntityTaxon

import org.semanticweb.owlapi.model.OWLDataFactory; //導入依賴的package包/類
public String getEntityTaxon(String curie, OWLOntology model) throws UnknownIdentifierException {
	if (curie == null || curie.isEmpty()) {
		return null;
	}
	OWLDataFactory df = model.getOWLOntologyManager().getOWLDataFactory();
	OWLClass cls = df.getOWLClass(curieHandler.getIRI(curie));
	String taxon = getEntityTaxon(cls, model);
	if (taxon == null) {
		OWLGraphWrapper g = new OWLGraphWrapper(model);
		cls = g.getOWLClassByIdentifier(curie);
		if (cls != null) {
			taxon = getEntityTaxon(cls, model);
		}
		IOUtils.closeQuietly(g);
	}
	return taxon;
}
 
開發者ID:geneontology,項目名稱:minerva,代碼行數:18,代碼來源:FindTaxonTool.java

示例5: addBioEntity

import org.semanticweb.owlapi.model.OWLDataFactory; //導入依賴的package包/類
private void addBioEntity(OWLClass pr, OWLOntology lego, Bioentity bioentity) {
	Set<OWLDeclarationAxiom> declarationAxioms = lego.getDeclarationAxioms(pr);
	if (declarationAxioms == null || declarationAxioms.isEmpty()) {
		// add class declaration and add label
		OWLOntologyManager m = lego.getOWLOntologyManager();
		OWLDataFactory f = m.getOWLDataFactory();
		
		Set<OWLAxiom> axioms = new HashSet<OWLAxiom>();
		axioms.add(f.getOWLDeclarationAxiom(pr));
		
		String label = bioentity.getSymbol()+" - "+bioentity.getFullName();
		
		axioms.add(f.getOWLAnnotationAssertionAxiom(f.getRDFSLabel(), pr.getIRI(), f.getOWLLiteral(label)));
		
		m.addAxioms(lego, axioms);
	}
}
 
開發者ID:geneontology,項目名稱:minerva,代碼行數:18,代碼來源:GafToLegoTranslator.java

示例6: testExactSynonym

import org.semanticweb.owlapi.model.OWLDataFactory; //導入依賴的package包/類
private void testExactSynonym(OWLOntology ontology) {
	IRI iri = IRI.create("http://www.geneontology.org/formats/oboInOwl#hasExactSynonym");
	OWLDataFactory df = ontology.getOWLOntologyManager().
		getOWLDataFactory();
	OWLAnnotationProperty property = df.getOWLAnnotationProperty(iri);
	assertTrue("Exact Synonym property in signature",
		ontology.containsAnnotationPropertyInSignature(iri));
	
	// Check axioms
	Set<OWLAnnotationAxiom> axioms = ontology.getAxioms(property, Imports.EXCLUDED);
	assertEquals("Count class axioms", 0, axioms.size());

	// Check annotations
	List<String> values = new ArrayList<String>();
	values.add("AnnotationAssertion(rdfs:label <http://www.geneontology.org/formats/oboInOwl#hasExactSynonym> \"has_exact_synonym\"^^xsd:string)");

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

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

示例7: 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

示例8: parseRow

import org.semanticweb.owlapi.model.OWLDataFactory; //導入依賴的package包/類
private void parseRow(String[] row) {
	OWLDataFactory df = graph.getDataFactory();
	OWLOntologyManager mgr = graph.getManager();
	String geneSetId = row[0];
	IRI geneSetIRI = IRI.create(prefix + geneSetId);
	String desc = row[1];
	OWLClass geneSetCls = df.getOWLClass(geneSetIRI);
	OWLAxiom ax = df.getOWLAnnotationAssertionAxiom(df.getRDFSLabel(),geneSetIRI, literal(desc));
	mgr.addAxiom(graph.getSourceOntology(), ax);
			
	// assume each value is an entity, e.g. gene
	for (int i=2; i < row.length; i++) {
		OWLNamedIndividual individual = df.getOWLNamedIndividual(IRI.create(prefix + row[i]));
		mgr.addAxiom(graph.getSourceOntology(), df.getOWLClassAssertionAxiom(geneSetCls, individual));
	}
}
 
開發者ID:owlcollab,項目名稱:owltools,代碼行數:17,代碼來源:GMTParser.java

示例9: 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,代碼來源:KBStandaloneLoader.java

示例10: addPTBoxConstraints

import org.semanticweb.owlapi.model.OWLDataFactory; //導入依賴的package包/類
protected void addPTBoxConstraints(OWLOntology ontology, PTBox ptbox,
										OWLOntologyManager manager, OWLDataFactory  factory) {
	
	ConceptConverter converter = new ConceptConverter(ptbox.getClassicalKnowledgeBase(), factory); 
	
	for (ConditionalConstraint cc : ptbox.getDefaultConstraints()) {

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

示例11: getObjectPropertyInstances

import org.semanticweb.owlapi.model.OWLDataFactory; //導入依賴的package包/類
public Map<OWLNamedIndividual, Set<OWLNamedIndividual>> getObjectPropertyInstances(
		OWLObjectProperty property) {
	checkPreConditions(property);
	Map<OWLNamedIndividual, Set<OWLNamedIndividual>> result = new HashMap<OWLNamedIndividual, Set<OWLNamedIndividual>>();
	if (!m_isConsistent) {
		Set<OWLNamedIndividual> all = getAllNamedIndividuals();
		for (OWLNamedIndividual ind : all)
			result.put(ind, all);
		return result;
	}
	initialisePropertiesInstanceManager();
	AtomicRole role = H(property);
	Map<Individual, Set<Individual>> relations = m_instanceManager
			.getObjectPropertyInstances(role);
	OWLDataFactory factory = getDataFactory();
	for (Individual individual : relations.keySet()) {
		Set<OWLNamedIndividual> successors = new HashSet<OWLNamedIndividual>();
		result.put(factory.getOWLNamedIndividual(IRI.create(individual
				.getIRI())), successors);
		for (Individual successorIndividual : relations.get(individual))
			successors.add(factory.getOWLNamedIndividual(IRI
					.create(successorIndividual.getIRI())));
	}
	return result;
}
 
開發者ID:evalincius,項目名稱:Hermit_1.3.8_android,代碼行數:26,代碼來源:Reasoner.java

示例12: 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

示例13: computeDescriptiveStatistics

import org.semanticweb.owlapi.model.OWLDataFactory; //導入依賴的package包/類
protected DescriptiveStatistics computeDescriptiveStatistics(Set<OWLClass> attributes) throws UnknownOWLClassException  {
	DescriptiveStatistics statsPerAttSet = new DescriptiveStatistics();
	OWLDataFactory g = sourceOntology.getOWLOntologyManager().getOWLDataFactory();

	for (OWLClass c : attributes) {
		Double ic;
		try {
			ic = owlsim.getInformationContentForAttribute(c);
			if (ic == null) { 
				if (g.getOWLClass(c.getIRI()) != null) {
					ic = owlsim.getSummaryStatistics().max.getMax();
				} else {
					throw new UnknownOWLClassException(c); }
			}
			if (ic.isInfinite() || ic.isNaN()) {
				ic = owlsim.getSummaryStatistics().max.getMax();
			}
			statsPerAttSet.addValue(ic);	

		} catch (UnknownOWLClassException e) {
			LOG.info("Unknown class "+c.toStringID()+" submitted for summary stats. Removed from calculation.");
			continue;
		}
	}
	return statsPerAttSet;
}
 
開發者ID:owlcollab,項目名稱:owltools,代碼行數:27,代碼來源:OWLSimReferenceBasedStatistics.java

示例14: parse

import org.semanticweb.owlapi.model.OWLDataFactory; //導入依賴的package包/類
public void parse(File myFile) throws IOException {
	try (BufferedReader reader = new BufferedReader(new FileReader(myFile))) {
		for(String line : IOUtils.readLines(reader)) {
			String[] row = line.split("\t");
			if (config.defaultCol1 != null)
				row[0] = config.defaultCol1;
			if (config.defaultCol2 != null) {
				String[] row2 = new String[2];
				row2[0] = row[0];
				row = row2;
				row[1] = config.defaultCol2;
			}
			addRow(row);
		}
	}

	if (config.individualsType != null) {
		OWLDataFactory df = graph.getDataFactory();
		graph.getManager().applyChange(new AddAxiom(graph.getSourceOntology(), 
				df.getOWLDeclarationAxiom(config.individualsType)));
	}

}
 
開發者ID:owlcollab,項目名稱:owltools,代碼行數:24,代碼來源:TableToAxiomConverter.java

示例15: createOWLLiteralFromValue

import org.semanticweb.owlapi.model.OWLDataFactory; //導入依賴的package包/類
/**
 * Creates OWLLiteral from the specified Java instance.
 *
 * @param value       The value to transform
 * @param dataFactory Data factory
 * @param lang        Ontology language
 * @return OWLLiteral representing the value
 * @throws IllegalArgumentException If {@code value} is of unsupported type
 */
public static OWLLiteral createOWLLiteralFromValue(Object value, OWLDataFactory dataFactory, String lang) {
    Objects.requireNonNull(value);
    if (value instanceof Integer) {
        // Java implementations map int/Integer to xsd:int, because xsd:integer is unbounded, whereas xsd:int is 32-bit signed, same as Java
        return dataFactory.getOWLLiteral(value.toString(), OWL2Datatype.XSD_INT);
    } else if (value instanceof Long) {
        return dataFactory.getOWLLiteral(value.toString(), OWL2Datatype.XSD_LONG);
    } else if (value instanceof Boolean) {
        return dataFactory.getOWLLiteral((Boolean) value);
    } else if (value instanceof Double) {
        return dataFactory.getOWLLiteral((Double) value);
    } else if (value instanceof String) {
        return dataFactory.getOWLLiteral((String) value, lang);
    } else if (value instanceof Date) {
        SimpleDateFormat sdf = new SimpleDateFormat(DATE_TIME_FORMAT);
        return dataFactory.getOWLLiteral(sdf.format(((Date) value)),
                dataFactory.getOWLDatatype(OWL2Datatype.XSD_DATE_TIME.getIRI()));
    } else if (value.getClass().isEnum()) {
        return dataFactory.getOWLLiteral(value.toString());
    } else {
        throw new IllegalArgumentException("Unsupported value " + value + " of type " + value.getClass());
    }
}
 
開發者ID:kbss-cvut,項目名稱:jopa,代碼行數:33,代碼來源:OwlapiUtils.java


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