当前位置: 首页>>代码示例>>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;未经允许,请勿转载。