本文整理汇总了Java中org.semanticweb.owlapi.model.OWLEntity类的典型用法代码示例。如果您正苦于以下问题:Java OWLEntity类的具体用法?Java OWLEntity怎么用?Java OWLEntity使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OWLEntity类属于org.semanticweb.owlapi.model包,在下文中一共展示了OWLEntity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPrefLabels
import org.semanticweb.owlapi.model.OWLEntity; //导入依赖的package包/类
@Override
public Set<String> getPrefLabels(OWLEntity cpt) {
Set<String> finalLabels = new HashSet<String>();
Set<OWLAnnotation> annotations = cpt.getAnnotations(ontology);
for(OWLAnnotation annot : annotations) {
if(annot.getValue() instanceof OWLLiteral) {
OWLAnnotationProperty prop = annot.getProperty();
// The DOE prefLabel, if they exist
if(prop.getIRI().equals(prefLabelIRI) ||
prop.getIRI().equals(SKOSVocabulary.PREFLABEL.getIRI()) ||
prop.getIRI().equals(OWLRDFVocabulary.RDFS_LABEL.getIRI())) {
OWLLiteral literal = (OWLLiteral)annot.getValue();
finalLabels.add(literal.getLiteral());
}
}
}
return finalLabels;
}
示例2: getAltLabels
import org.semanticweb.owlapi.model.OWLEntity; //导入依赖的package包/类
@Override
public Set<String> getAltLabels(OWLEntity cpt) {
Set<String> finalLabels = new HashSet<String>();
Set<OWLAnnotation> annotations = cpt.getAnnotations(ontology);
for(OWLAnnotation annot : annotations) {
if(annot.getValue() instanceof OWLLiteral) {
OWLAnnotationProperty prop = annot.getProperty();
// The DOE prefLabel, if they exist
if(prop.getIRI().equals(altLabelIRI) ||
prop.getIRI().equals(hiddenLabelIRI) ||
prop.getIRI().equals(SKOSVocabulary.ALTLABEL.getIRI()) ||
prop.getIRI().equals(SKOSVocabulary.HIDDENLABEL.getIRI())) {
OWLLiteral literal = (OWLLiteral)annot.getValue();
finalLabels.add(literal.getLiteral());
}
}
}
return finalLabels;
}
示例3: getAltLabels
import org.semanticweb.owlapi.model.OWLEntity; //导入依赖的package包/类
@Override
public Set<String> getAltLabels(OWLEntity cpt) {
if(cpt == null)
throw new IllegalArgumentException("cpt cannot be null");
// The rdfs:label, if it exists
Set<String> finalLabels = new HashSet<String>();
Set<OWLAnnotation> annotations = cpt.getAnnotations(
ontology,
df.getOWLAnnotationProperty(OWLRDFVocabulary.RDFS_LABEL.getIRI()));
for(OWLAnnotation annot : annotations) {
if(annot.getValue() instanceof OWLLiteral) {
finalLabels.add(((OWLLiteral)annot.getValue()).getLiteral());
}
}
return finalLabels;
}
示例4: getChildren
import org.semanticweb.owlapi.model.OWLEntity; //导入依赖的package包/类
@Override
public Set<OWLEntity> getChildren(OWLEntity cpt) {
if(!cpt.isOWLClass()) return new HashSet<OWLEntity>();
Set<OWLEntity> entities = new HashSet<OWLEntity>();
Set<OWLEntity> result = new HashSet<OWLEntity>();
OWLClass localRootClass = cpt.asOWLClass();
entities.addAll(reasoner.getSubClasses(localRootClass, true).getFlattened());
entities.addAll(reasoner.getInstances(localRootClass, true).getFlattened());
for(OWLEntity child : entities) {
// Only Class or Named individual
if(!child.isOWLClass() && !child.isOWLNamedIndividual())
{
continue;
}
// Not Nothing
if(child.isOWLClass() && child.asOWLClass().isOWLNothing())
{
continue;
}
result.add(child);
}
return result;
}
示例5: getParents
import org.semanticweb.owlapi.model.OWLEntity; //导入依赖的package包/类
@Override
public Set<OWLEntity> getParents(OWLEntity cpt) {
if(!cpt.isOWLClass()) return new HashSet<OWLEntity>();
Set<OWLEntity> entities = new HashSet<OWLEntity>();
Set<OWLEntity> result = new HashSet<OWLEntity>();
OWLClass localRootClass = cpt.asOWLClass();
entities.addAll(reasoner.getSuperClasses(localRootClass, true).getFlattened());
for(OWLEntity parentClass : entities) {
// Only Class
if(!parentClass.isOWLClass())
{
continue;
}
// Not Nothing
if(parentClass.isOWLClass() && parentClass.asOWLClass().isOWLNothing())
{
continue;
}
result.add(parentClass);
}
return result;
}
示例6: highlightPropertyIfUnsatisfiable
import org.semanticweb.owlapi.model.OWLEntity; //导入依赖的package包/类
private void highlightPropertyIfUnsatisfiable(final OWLEntity entity, final StyledDocument doc,
final int tokenStartIndex, final int tokenLength) {
try {
getOWLModelManager().getReasonerPreferences()
.executeTask(OptionalInferenceTask.SHOW_OBJECT_PROPERTY_UNSATISFIABILITY, () -> {
OWLObjectProperty prop = (OWLObjectProperty) entity;
OWLReasoner reasoner = getOWLModelManager().getReasoner();
boolean consistent = reasoner.isConsistent();
if (!consistent || reasoner.getBottomObjectPropertyNode().contains(prop)) {
doc.setCharacterAttributes(tokenStartIndex, tokenLength, inconsistentClassStyle, true);
}
});
} catch (Exception e) {
logger.warn("An error occurred whilst highlighting an unsatisfiable property: {}", e);
}
}
示例7: minimizedTranslate
import org.semanticweb.owlapi.model.OWLEntity; //导入依赖的package包/类
/**
* Translate the given {@link GafDocument} into an OWL representation of the LEGO model.
* Additionally minimize the lego model and imports into one ontology module.
*
* @param gaf
* @return minimized lego ontology
*/
public OWLOntology minimizedTranslate(GafDocument gaf) {
OWLOntology all = translate(gaf);
final OWLOntologyManager m = all.getOWLOntologyManager();
SyntacticLocalityModuleExtractor sme = new SyntacticLocalityModuleExtractor(m, all, ModuleType.BOT);
Set<OWLEntity> sig = new HashSet<OWLEntity>(all.getIndividualsInSignature());
Set<OWLAxiom> moduleAxioms = sme.extract(sig);
try {
OWLOntology module = m.createOntology(IRI.generateDocumentIRI());
m.addAxioms(module, moduleAxioms);
return module;
} catch (OWLException e) {
throw new RuntimeException("Could not create minimized lego model.", e);
}
}
示例8: initialise
import org.semanticweb.owlapi.model.OWLEntity; //导入依赖的package包/类
@Override
public void initialise() throws Exception {
System.out.println("Initializing DL-Learner plugin for " + getAxiomType().getName() + " axioms...");
// initialize the manager
Manager manager = Manager.getInstance(getOWLEditorKit());
manager.setAxiomType(getAxiomType());
// create the view
view = new DLLearnerView(getOWLEditorKit(),
getOWLEditorKit().getOWLWorkspace().getOWLSelectionModel().getSelectedEntity(),
getAxiomType());
manager.setProgressMonitor(view.getStatusBar());
manager.addProgressMonitor(view);
OWLEntity entity = getOWLEditorKit().getOWLWorkspace().getOWLSelectionModel().getSelectedEntity();
manager.setEntity(entity);
// add listeners
addListeners();
ToStringRenderer.getInstance().setRenderer(new DLSyntaxObjectRenderer());
}
示例9: createOverlappingEstimation
import org.semanticweb.owlapi.model.OWLEntity; //导入依赖的package包/类
private void createOverlappingEstimation(OWLOntology ontology, Set<OWLEntity> entities, Set<OWLAxiom> overlapping){
//Module: overlapping overestimation
OntologyModuleExtractor module_extractor =
new OntologyModuleExtractor(
SynchronizedOWLManager.createOWLOntologyManager(),
ontology.getAxioms(),
true,
false,
true);
//OWLOntology module_source = module_extractor_source.extractAsOntology(
// entities_source,
// IRI.create(source.getOntologyID().getOntologyIRI().toString()));
overlapping = module_extractor.extract(entities);
module_extractor.clearStrutures();
//Remove original ontology
ontology.getOWLOntologyManager().removeOntology(ontology);
ontology=null;
entities.clear();
}
示例10: owlObjectToType
import org.semanticweb.owlapi.model.OWLEntity; //导入依赖的package包/类
private <T> T owlObjectToType(OWLObject owlValue, Class<T> cls) throws OntoDriverException {
if (cls.isAssignableFrom(owlValue.getClass())) {
return cls.cast(owlValue);
}
if (owlValue instanceof OWLLiteral) {
final Object ob = OwlapiUtils.owlLiteralToValue((OWLLiteral) owlValue);
if (cls.isAssignableFrom(ob.getClass())) {
return cls.cast(ob);
}
} else {
final Set<OWLEntity> sig = owlValue.getSignature();
if (!sig.isEmpty()) {
final URI uri = URI.create(sig.iterator().next().toStringID());
if (cls.isAssignableFrom(uri.getClass())) {
return cls.cast(uri);
}
return tryInstantiatingClassUsingConstructor(cls, uri);
}
}
throw new OwlapiDriverException("Conversion to type " + cls + " is not supported.");
}
示例11: visit
import org.semanticweb.owlapi.model.OWLEntity; //导入依赖的package包/类
@Override
public Set<ComplexIntegerAxiom> visit(OWLDeclarationAxiom axiom) {
Objects.requireNonNull(axiom);
OWLEntity entity = axiom.getEntity();
if (entity.isOWLClass()) {
return declare(entity.asOWLClass(), axiom.getAnnotations());
} else if (entity.isOWLObjectProperty()) {
return declare(entity.asOWLObjectProperty(), axiom.getAnnotations());
} else if (entity.isOWLNamedIndividual()) {
return declare(entity.asOWLNamedIndividual(), axiom.getAnnotations());
} else if (entity.isOWLDataProperty()) {
return declare(entity.asOWLDataProperty(), axiom.getAnnotations());
} else if (entity.isOWLAnnotationProperty()) {
// FIXME add annotation property
return Collections.emptySet();
} else {
throw TranslationException.newUnsupportedAxiomException(axiom);
}
}
示例12: calculatePairwiseEnrichment
import org.semanticweb.owlapi.model.OWLEntity; //导入依赖的package包/类
/**
* @param populationClass
* @param sampleSetClass
* @param enrichedClass
* @return enrichment
* @throws MathException
*/
public EnrichmentResult calculatePairwiseEnrichment(OWLClass populationClass,
OWLClass sampleSetClass, OWLClass enrichedClass) throws MathException {
HypergeometricDistributionImpl hg =
new HypergeometricDistributionImpl(
getNumElementsForAttribute(populationClass),
getNumElementsForAttribute(sampleSetClass),
getNumElementsForAttribute(enrichedClass)
);
/*
LOG.info("popsize="+getNumElementsForAttribute(populationClass));
LOG.info("sampleSetSize="+getNumElementsForAttribute(sampleSetClass));
LOG.info("enrichedClass="+getNumElementsForAttribute(enrichedClass));
*/
Set<OWLEntity> eiSet = getElementsForAttribute(sampleSetClass);
eiSet.retainAll(this.getElementsForAttribute(enrichedClass));
//LOG.info("both="+eiSet.size());
double p = hg.cumulativeProbability(eiSet.size(),
Math.min(getNumElementsForAttribute(sampleSetClass),
getNumElementsForAttribute(enrichedClass)));
double pCorrected = p * getCorrectionFactor(populationClass);
return new EnrichmentResult(sampleSetClass, enrichedClass, p, pCorrected);
}
示例13: addElement
import org.semanticweb.owlapi.model.OWLEntity; //导入依赖的package包/类
private Set<OWLClass> addElement(OWLEntity e, Set<OWLClass> atts) {
// TODO - fully fold TBox so that expressions of form (inh (part_of x))
// generate a class "part_of x", to ensure that a SEP grouping class is created
Set<OWLClass> attClasses = new HashSet<OWLClass>();
for (OWLClass attClass : atts) {
// filtering, e.g. Type :human. This is a somewhat unsatisfactory way to do this;
// better to filter at the outset
if (attClass instanceof OWLClass && ignoreSubClassesOf != null && ignoreSubClassesOf.size() > 0) {
if (this.getReasoner().getSuperClasses(attClass, false).getFlattened().retainAll(ignoreSubClassesOf)) {
continue;
}
}
if (!this.attributeToElementsMap.containsKey(attClass))
attributeToElementsMap.put(attClass, new HashSet<OWLEntity>());
attributeToElementsMap.get(attClass).add(e);
attClasses.add(attClass);
}
// note this only caches direct associations
this.elementToAttributesMap.put(e, attClasses);
return attClasses;
}
示例14: precomputeAttributeElementCount
import org.semanticweb.owlapi.model.OWLEntity; //导入依赖的package包/类
public void precomputeAttributeElementCount() {
if (attributeElementCount != null)
return;
attributeElementCount = new HashMap<OWLClass, Integer>();
for (OWLEntity e : this.getAllElements()) {
LOG.info("Adding 1 to all attributes of "+e);
for (OWLClass dc : getAttributesForElement(e)) {
for (Node<OWLClass> n : this.getNamedReflexiveSubsumers(dc)) {
for (OWLClass c : n.getEntities()) {
if (!attributeElementCount.containsKey(c))
attributeElementCount.put(c, 1);
else
attributeElementCount.put(c, attributeElementCount.get(c)+1);
}
}
}
}
}
示例15: getExternalReferencedEntities
import org.semanticweb.owlapi.model.OWLEntity; //导入依赖的package包/类
/**
*
* returns set of entities that belong to a referenced ontology that are referenced in the source ontology.
*
* If the source ontology is not explicitly declared, then all entities that are referenced in the source
* ontology and declared in a reference ontology are returned.
*
* Example: if the source ontology is cl, and cl contains axioms that reference go:1, go:2, ...
* and go is in the set of referenced ontologies, then {go:1,go:2,...} will be in the returned set.
* It is irrelevant whether go:1, ... is declared in the source (e.g. MIREOTed)
*
* Note this only returns direct references. See
* {@link #getClosureOfExternalReferencedEntities()} for closure of references
*
* @return all objects referenced by source ontology
*/
public Set<OWLEntity> getExternalReferencedEntities() {
OWLOntology ont = graph.getSourceOntology();
Set<OWLEntity> objs = ont.getSignature(Imports.EXCLUDED);
Set<OWLEntity> refObjs = new HashSet<OWLEntity>();
LOG.info("testing "+objs.size()+" objs to see if they are contained in: "+getReferencedOntologies());
for (OWLEntity obj : objs) {
//LOG.info("considering: "+obj);
// a reference ontology may have entities from the source ontology MIREOTed in..
// allow a configuration with the URI prefix specified
if (isInExternalOntology(obj)) {
refObjs.add(obj);
}
}
LOG.info("#refObjs: "+refObjs.size());
return refObjs;
}