org.semanticweb.owlapi.model.OWLEntity Java Examples

The following examples show how to use org.semanticweb.owlapi.model.OWLEntity. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OldSimpleOwlSim.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
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);
				}
			}

		}
	}
}
 
Example #2
Source File: OldSimpleOwlSim.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
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;
}
 
Example #3
Source File: Mooncat.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * 
 * 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;
}
 
Example #4
Source File: NameRedundancyCheck.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private List<IRI> renderEntities(Collection<? extends OWLEntity> entities, StringBuilder sb, OWLGraphWrapper g, List<IRI> iris) {
	boolean first = true;
	for(OWLEntity entity : entities) {
		String entityLabel = g.getLabel(entity);
		IRI iri = entity.getIRI();
		iris.add(iri);
		if (first) {
			first = false;
		}
		else {
			sb.append("; ");
		}
		sb.append(iri.toQuotedString());
		if (entityLabel != null) {
			sb.append(" '").append(entityLabel).append("'");
		}
	}
	return iris;
}
 
Example #5
Source File: QuotedEntityChecker.java    From robot with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Add a specific mapping to the given entity.
 *
 * @param entity the entity to add mappings for
 * @param name the name to map to this entity
 */
public void add(OWLEntity entity, String name) {
  if (entity == null) {
    return;
  }

  Map<String, IRI> map = pickMap(entity);
  if (map == null) {
    logger.info("Unknown OWL entity type for: " + entity);
    return;
  }

  labels.put(entity.getIRI(), name);
  iris.put(name, entity.getIRI());
  map.put(name, entity.getIRI());
}
 
Example #6
Source File: QuotedEntityChecker.java    From robot with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Given an entity, return the right map for it.
 *
 * @param entity the entity to find a map for
 * @return the right map for the entity, or null
 */
private Map<String, IRI> pickMap(OWLEntity entity) {
  Map<String, IRI> map = null;
  if (entity.isOWLAnnotationProperty()) {
    map = annotationProperties;
  } else if (entity.isOWLObjectProperty()) {
    map = objectProperties;
  } else if (entity.isOWLDataProperty()) {
    map = dataProperties;
  } else if (entity.isOWLDatatype()) {
    map = datatypes;
  } else if (entity.isOWLClass()) {
    map = classes;
  } else if (entity.isOWLNamedIndividual()) {
    map = namedIndividuals;
  }
  return map;
}
 
Example #7
Source File: QuotedEntityChecker.java    From robot with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Find any entity with the given name. Quotation marks will be removed if necessary.
 *
 * @param name the name of the entity to find
 * @return an entity, or null
 */
public OWLEntity getOWLEntity(String name) {
  if (annotationProperties.containsKey(name)) {
    return getOWLAnnotationProperty(name);
  } else if (objectProperties.containsKey(name)) {
    return getOWLObjectProperty(name);
  } else if (dataProperties.containsKey(name)) {
    return getOWLDataProperty(name);
  } else if (datatypes.containsKey(name)) {
    return getOWLDatatype(name);
  } else if (namedIndividuals.containsKey(name)) {
    return getOWLIndividual(name);
  } else if (classes.containsKey(name)) {
    return getOWLClass(name);
  }
  return null;
}
 
Example #8
Source File: GetLabelsTest.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private String getLabel(OWLEntity obj) throws MultiLabelException {
	String label = null;
	OWLAnnotationProperty labelProperty = ont.getOWLOntologyManager().getOWLDataFactory().getRDFSLabel();
	for (OWLAnnotation ann : OwlHelper.getAnnotations(obj, labelProperty, ont)) {
		if (ann.getProperty().isLabel()) {
			OWLAnnotationValue v = ann.getValue();
			if (v instanceof OWLLiteral) {
				if (label != null) {
					throw new MultiLabelException(obj);
				}
				label = ((OWLLiteral)v).getLiteral();
			}
		}
	}
	return label;
}
 
Example #9
Source File: AbstractOWLOntologyLoader.java    From BioSolr with Apache License 2.0 6 votes vote down vote up
protected Optional<String> evaluateLabelAnnotationValue(OWLEntity entity, OWLAnnotationValue value) {
    // get label annotations
    Optional<String> label = getOWLAnnotationValueAsString(value);
    if (!label.isPresent()) {
        // try and get the URI fragment and use that as label
        Optional<String> fragment = getShortForm(entity.getIRI());
        if (fragment.isPresent()) {
            return Optional.of(fragment.get());
        }
        else {
            getLog().warn("OWLEntity " + entity + " contains no label. " +
                    "No labels for this class will be loaded.");
            return  Optional.of(entity.toStringID());
        }
    }
    return label;
}
 
Example #10
Source File: OWLConverter.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Add an synonym annotation, plus an annotation on that annotation
 * that specified the type of synonym. The second annotation has the
 * property oio:hasSynonymType.
 *
 * @param ontology the current ontology
 * @param subject the subject of the annotation
 * @param type the IRI of the type of synonym
 * @param property the IRI of the annotation property.
 * @param value the literal value of the synonym
 * @return the synonym annotation axiom
 */
protected static OWLAnnotationAssertionAxiom synonym(
		OWLOntology ontology, OWLEntity subject, 
		OWLAnnotationValue type,
		OWLAnnotationProperty property, 
		OWLAnnotationValue value) {
	OWLOntologyManager manager = ontology.getOWLOntologyManager();
	OWLDataFactory dataFactory = manager.getOWLDataFactory();
	OWLAnnotationProperty hasSynonymType =
		dataFactory.getOWLAnnotationProperty(
			format.getIRI("oio:hasSynonymType"));
	OWLAnnotation annotation = 
		dataFactory.getOWLAnnotation(hasSynonymType, type);
	Set<OWLAnnotation> annotations = new HashSet<OWLAnnotation>();
	annotations.add(annotation);
	OWLAnnotationAssertionAxiom axiom =
		dataFactory.getOWLAnnotationAssertionAxiom(
			property, subject.getIRI(), value,
			annotations);
	manager.addAxiom(ontology, axiom);
	return axiom;
}
 
Example #11
Source File: OWLGraphWrapperExtended.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Get the definition xrefs (IAO_0000115)
 * 
 * @param c
 * @return list of definition xrefs
 */
public List<String> getDefXref(OWLObject c){
	OWLAnnotationProperty lap = getDataFactory().getOWLAnnotationProperty(Obo2OWLVocabulary.IRI_IAO_0000115.getIRI()); 
	OWLAnnotationProperty xap = getAnnotationProperty(OboFormatTag.TAG_XREF.getTag());

	if (c instanceof OWLEntity) {
		List<String> list = new ArrayList<String>();
		for (OWLOntology ont : getAllOntologies()) {
			Set<OWLAnnotationAssertionAxiom> axioms = ont.getAnnotationAssertionAxioms(((OWLEntity) c).getIRI());
			for (OWLAnnotationAssertionAxiom axiom :axioms){
				if(lap.equals(axiom.getProperty())){
					for(OWLAnnotation annotation: axiom.getAnnotations(xap)){
						OWLAnnotationValue value = annotation.getValue();
						if(value instanceof OWLLiteral){
							list.add(((OWLLiteral)value).getLiteral());
						}
					}
				}

			}
		}
		return list;
	}
	else {
		return null;
	}
}
 
Example #12
Source File: Mooncat.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public boolean belongsToSource(OWLEntity obj) {
	if (getOntology().getDeclarationAxioms((OWLEntity) obj).size() > 0) {
		if (!isDangling(getOntology(),obj)) {
			return true;
		}
	}
	return false;
}
 
Example #13
Source File: Mooncat.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * finds the full closure of all external referenced entities.
 * TODO: include object properties
 * 
 * calls {@link #getExternalReferencedEntities()} and then finds all reflexive ancestors of this set.
 * 
 * to configure the traversal, see {@link OWLGraphWrapper}
 * 
 * @return closure of all external referenced entities
 */
public Set<OWLObject> getClosureOfExternalReferencedEntities() {
	// the closure set, to be returned
	Set<OWLObject> objs = new HashSet<OWLObject>();

	// set of entities in external ontologies referenced in source ontology
	Set<OWLEntity> refs = getExternalReferencedEntities();
	LOG.info("direct external referenced entities: "+refs.size());

	// build the closure
	for (OWLEntity ref : refs) {
		// todo - allow per-relation control
		// todo - make more efficient, allow passing of set of entities
		// todo - include object properties
		Set<OWLObject> ancs = graph.getAncestorsReflexive(ref);
		objs.addAll(ancs);
	}
	LOG.info("closure of direct external referenced entities: "+objs.size());

	// extraObjs is the set of properties (annotation and object)
	// that are in the signatures of all referencing axioms
	Set<OWLObject> extraObjs = new HashSet<OWLObject>();
	for (OWLObject obj : objs) {
		if (obj instanceof OWLEntity) {
			for (OWLOntology refOnt : this.getReferencedOntologies()) {
				for (OWLAnnotationAssertionAxiom aaa : refOnt.getAnnotationAssertionAxioms(((OWLEntity)obj).getIRI())) {
					extraObjs.add(aaa.getProperty());
					extraObjs.add(aaa.getValue());
				}
				
				for (OWLAxiom ax : refOnt.getReferencingAxioms((OWLEntity)obj)) {
					extraObjs.addAll(ax.getObjectPropertiesInSignature());
				}
			}
		}
	}
	objs.addAll(extraObjs);
	return objs;
}
 
Example #14
Source File: Mooncat.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private boolean isInExternalOntology(OWLEntity obj) {
	if (sourceOntologyPrefixes != null && sourceOntologyPrefixes.size() > 0) {
		//LOG.info("  prefixes: "+sourceOntologyPrefixes);
		String iri = obj.getIRI().toString();
		boolean isSrc = false;
		for (String prefix : sourceOntologyPrefixes) {
			if (iri.startsWith(prefix)) {
				isSrc = true;
				break;
			}
		}
		if (!isSrc) {
			LOG.info("  refObj: "+obj+" // "+sourceOntologyPrefixes);
			return true;
		}
	}
	else {
		// estimate by ref ontologies
		// TODO: this is not reliable
		for (OWLOntology refOnt : getReferencedOntologies()) {
			//LOG.info("  refOnt: "+refOnt);
			if (refOnt.getDeclarationAxioms(obj).size() > 0) {
				if (LOG.isDebugEnabled()) {
					LOG.debug("  refObj: " + obj);
				}
				return true;
			}
		}
	}
	return false;
}
 
Example #15
Source File: EquivalenceSetMergeUtil.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private Double getScore(OWLEntity c, Map<String, Double> pmap) {
	for (String p : pmap.keySet()) {
		if (hasPrefix(c,p)) {
			return pmap.get(p);
		}
	}
	return null;
}
 
Example #16
Source File: OWLGraphWrapperExtended.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Generate a OboGraphs JSON ontology blob for the local axioms for an object.
 * 
 * This will include
 * 
 *  - all logical axioms about the object
 *  - all annotations for all entities in the signature
 *  
 * In other words, direct parents plus labels and other metadata on all entities
 * 
 * @param obj
 * @return JSON string
 * @throws JsonProcessingException
 * @throws OWLOntologyCreationException
 */
public String getOboGraphJSONString(OWLObject obj) throws JsonProcessingException, OWLOntologyCreationException {
	FromOwl fromOwl = new FromOwl();
	OWLOntologyManager m = sourceOntology.getOWLOntologyManager();
	if (obj instanceof OWLNamedObject) {
		OWLNamedObject nobj = (OWLNamedObject)obj;
		OWLOntology ont = m.createOntology(nobj.getIRI());
		Set<OWLAxiom> axioms = new HashSet<>();
		if (nobj instanceof OWLClass) {
			axioms.addAll(sourceOntology.getAxioms((OWLClass)nobj, Imports.INCLUDED));
		}
		else if (nobj instanceof OWLObjectProperty) {
			axioms.addAll(sourceOntology.getAxioms((OWLObjectProperty)nobj, Imports.INCLUDED));
		}
		m.addAxioms(ont, axioms);
		axioms = new HashSet<>();
		for (OWLEntity e : ont.getSignature()) {
			axioms.addAll(sourceOntology.getAnnotationAssertionAxioms(e.getIRI()));
		}
		axioms.addAll(sourceOntology.getAnnotationAssertionAxioms(nobj.getIRI()));
		m.addAxioms(ont, axioms);

		GraphDocument gd = fromOwl.generateGraphDocument(ont);
		return OgJsonGenerator.render(gd);
	}
	else {
		return "{}";
	}

}
 
Example #17
Source File: OWLGraphWrapperExtended.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public boolean isOboAltId(OWLEntity e) {
	Set<OWLAnnotationAssertionAxiom> axioms = new HashSet<>();
	for(OWLOntology ont : getAllOntologies()) {
		axioms.addAll(ont.getAnnotationAssertionAxioms(e.getIRI()));
	}
	return isOboAltId(axioms);
}
 
Example #18
Source File: TransformationUtils.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
protected static IRI getSkolemIRI(List<OWLEntity> objs) {
	// 
	IRI iri;
	StringBuffer sb = new StringBuffer();
	for (OWLEntity obj : objs) {
		sb.append("_"+getFragmentID(obj));
	}
	iri = IRI.create("http://x.org"+sb.toString());
	return iri;
}
 
Example #19
Source File: PropertyViewOntologyBuilder.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private String getAnyLabel(OWLEntity c) {
	String label = getLabel(c, sourceOntology);
	if (label == null) {
		// non-OBO-style ontology
		label = c.getIRI().getFragment();
		if (label == null) {
			label = c.getIRI().toString();
			label = label.replaceAll(".*/", "");
		}
	}
	return label;
}
 
Example #20
Source File: OldSimpleOwlSim.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private String getLabel(OWLEntity e) {
	String label = null;		
	// todo - ontology import closure
	OWLAnnotationProperty property = owlDataFactory.getRDFSLabel();
	for (OWLAnnotation ann : OwlHelper.getAnnotations(e, property, sourceOntology)) {
		OWLAnnotationValue v = ann.getValue();
		if (v instanceof OWLLiteral) {
			label = ((OWLLiteral)v).getLiteral();
			break;
		}
	}
	return label;
}
 
Example #21
Source File: OWLGraphWrapperExtended.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * tests if an OWLObject has been declared obsolete in the graph.
 * 
 * @param c
 * @return boolean
 */
public boolean isObsolete(OWLObject c) {
	for (OWLOntology ont : getAllOntologies()) {
		for (OWLAnnotation ann : OwlHelper.getAnnotations((OWLEntity) c, ont)) {
			if (ann.isDeprecatedIRIAnnotation()) {
				return true;
			}
		}
	}
	return false;
}
 
Example #22
Source File: OwlHelper.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static Set<OWLAnnotation> getAnnotations(OWLEntity e, Set<OWLOntology> ontolgies) {
	Set<OWLAnnotation> annotations;
	if (e != null && ontolgies != null && !ontolgies.isEmpty()) {
		annotations = new HashSet<>();
		for(OWLOntology ont : ontolgies) {
			annotations.addAll(getAnnotations(e, ont));
		}
	}
	else {
		annotations = Collections.emptySet();
	}
	return annotations;
}
 
Example #23
Source File: OwlHelper.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static Set<OWLAnnotation> getAnnotations(OWLEntity e, OWLAnnotationProperty property, OWLOntology ont) {
	Set<OWLAnnotation> annotations;
	if (e != null && property != null && ont != null) {
		annotations = new HashSet<>();
		for (OWLAnnotationAssertionAxiom ax : ont.getAnnotationAssertionAxioms(e.getIRI())) {
			if (property.equals(ax.getProperty())) {
				annotations.add(ax.getAnnotation());
			}
		}
	}
	else {
		annotations = Collections.emptySet();
	}
	return annotations;
}
 
Example #24
Source File: EquivalenceSetMergeUtil.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private boolean hasPrefix(OWLEntity c, String p) {
	if (p.startsWith("http")) {
		return c.getIRI().toString().startsWith(p);
	}
	if (c.getIRI().toString().contains("/"+p))
		return true;
	if (c.getIRI().toString().contains("#"+p))
		return true;
	return false;
}
 
Example #25
Source File: OWLGraphWrapper.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private Set<ISynonym> getOBOSynonyms(OWLEntity e, Obo2OWLVocabulary vocabulary, OWLOntology ont) {
	OWLAnnotationProperty synonymProperty = getDataFactory().getOWLAnnotationProperty(vocabulary.getIRI());
	Set<OWLAnnotation> anns = OwlHelper.getAnnotations(e, synonymProperty, ont);
	Set<OWLAnnotationAssertionAxiom> annotationAssertionAxioms = ont.getAnnotationAssertionAxioms(e.getIRI());
	if (anns != null && !anns.isEmpty()) {
		Set<ISynonym> set = new HashSet<ISynonym>();
		for (OWLAnnotation a : anns) {
			if (a.getValue() instanceof OWLLiteral) {
				OWLLiteral val = (OWLLiteral) a.getValue();
				String label = val.getLiteral();
				if (label != null && label.length() > 0) {
					String category = null;
					Set<String> xrefs = null;
					SynonymDetails details = getOBOSynonymDetails(annotationAssertionAxioms, val, synonymProperty);
					if (details != null) {
						category = details.category;
						xrefs = details.xrefs;
					}
					Synonym s = new Synonym(label, vocabulary.getMappedTag(), category, xrefs);
					set.add(s);
				}
			}
		}
		if (!set.isEmpty()) {
			return set;
		}
	}
	return null;
}
 
Example #26
Source File: AbstractSimPreProcessor.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public String generateLabel(OWLClassExpression x) {
	StringBuffer sb = new StringBuffer();
	if (x instanceof OWLObjectSomeValuesFrom) {
		OWLObjectSomeValuesFrom svf = (OWLObjectSomeValuesFrom) x;	
		OWLObjectPropertyExpression p = svf.getProperty();
		if (propertyToFormatMap.containsKey(p)) {
			return String.format(propertyToFormatMap.get(p), generateLabel(svf.getFiller()));
		}
		else {
			String pStr = p.toString();
			if (p instanceof OWLEntity) {
				pStr = getAnyLabel((OWLEntity)p);
			}
			return pStr + " some "+generateLabel(svf.getFiller());
		}
	}
	else if (x instanceof OWLObjectIntersectionOf) {
		OWLObjectIntersectionOf oio = (OWLObjectIntersectionOf) x;
		for (OWLClassExpression op : oio.getOperands()) {
			if (sb.length() > 0) {
				sb.append(" and ");
			}
			sb.append(generateLabel(op));
		}
		return sb.toString();
	}
	else if (x instanceof OWLClass) {
		return this.getAnyLabel((OWLClass) x);
	}
	return x.toString();
}
 
Example #27
Source File: OntologyLoader.java    From molgenis with GNU Lesser General Public License v3.0 5 votes vote down vote up
public String extractOWLClassId(OWLEntity cls) {
  StringBuilder stringBuilder = new StringBuilder();
  String clsIri = cls.getIRI().toString();
  // Case where id is separated by #
  String[] split = null;
  if (clsIri.contains("#")) {
    split = clsIri.split("#");
  } else {
    split = clsIri.split("/");
  }
  stringBuilder.append(split[split.length - 1]);
  return stringBuilder.toString();
}
 
Example #28
Source File: AbstractSimPreProcessor.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public String getLabel(OWLEntity c, OWLOntology ont) {
	String label = null;		
	// todo - ontology import closure
	OWLAnnotationProperty property = getOWLDataFactory().getRDFSLabel();
	for (OWLAnnotation ann : OwlHelper.getAnnotations(c, property, ont)) {
		OWLAnnotationValue v = ann.getValue();
		if (v instanceof OWLLiteral) {
			label = ((OWLLiteral)v).getLiteral();
			break;
		}
	}
	return label;
}
 
Example #29
Source File: AbstractSimPreProcessor.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public Set<OWLClass> extractClassesFromDeclarations(Set<OWLAxiom> axs) {
	Set<OWLClass> cs = new HashSet<OWLClass>();
	for (OWLAxiom ax : axs) {
		if (ax instanceof OWLDeclarationAxiom) {
			OWLEntity e = ((OWLDeclarationAxiom)ax).getEntity();
			if (e instanceof OWLClass)
				cs.add((OWLClass) e);
		}
	}
	return cs;
}
 
Example #30
Source File: OntologyLoader.java    From molgenis with GNU Lesser General Public License v3.0 5 votes vote down vote up
public String getLabel(OWLEntity entity) {
  Set<String> annotation = getAnnotation(entity, OWLRDFVocabulary.RDFS_LABEL.toString());
  if (!annotation.isEmpty()) {
    return annotation.iterator().next();
  } else {
    return extractOWLClassId(entity);
  }
}