org.semanticweb.owlapi.model.OWLIndividual Java Examples

The following examples show how to use org.semanticweb.owlapi.model.OWLIndividual. 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: SimpleOntologyValues.java    From mobi with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * .
 */
public static OWLAnnotation owlapiAnnotation(Annotation anno) {
    // TODO: ??? Fix this.
    if (anno == null) {
        return null;
    }
    OWLAnnotationProperty owlAnnoProperty = owlapiAnnotationProperty(anno.getProperty());
    Value value = anno.getValue();
    if (value instanceof IRI) {
        org.semanticweb.owlapi.model.IRI iri = owlapiIRI((IRI) value);
        return new OWLAnnotationImpl(owlAnnoProperty, iri, Stream.empty());
    } else if (value instanceof Literal) {
        OWLLiteral literal = owlapiLiteral((Literal) value);
        return new OWLAnnotationImpl(owlAnnoProperty, literal, Stream.empty());
    } else if (value instanceof SimpleIndividual) {
        OWLIndividual individual = owlapiIndividual((SimpleIndividual) value);
        return new OWLAnnotationImpl(owlAnnoProperty, (OWLAnonymousIndividual) individual, Stream.empty());
    } else {
        throw new MobiOntologyException("Invalid annotation value");
    }
}
 
Example #2
Source File: OWLGraphWrapperEdges.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Find all edges of the form [i INST c] in the graph closure.
 * (this includes both direct assertions, plus assertions to objects
 *  that link to c via a chain of SubClassOf assertions)
 * <p> 
 * the semantics are the same as inferred ClassAssertion axioms
 * 
 * @param c owlClass
 * @return all individuals classified here via basic graph traversal
 */
public Set<OWLIndividual> getInstancesFromClosure(OWLClass c) {
	Set<OWLIndividual> ins = new HashSet<OWLIndividual>();
	for (OWLOntology o : getAllOntologies()) {
		// iterate through all individuals; sequential scan may be slow for
		// large knowledge bases
		for (OWLIndividual in : o.getIndividualsInSignature()) {
			for (OWLGraphEdge e : getEdgesBetween(in, c)) {
				List<OWLQuantifiedProperty> qps = e.getQuantifiedPropertyList();
				// check for edges of the form < i INSTANCE_OF c >
				// we exclude relation chaims, e.g. <i [INSTANCE_OF PART_OF-some] c>
				if (qps.size() == 1 && qps.get(0).isInstanceOf()) {
					ins.add(in);
					break;
				}
			}
		}
	}
	return ins;
}
 
Example #3
Source File: OWLInAboxTranslator.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * @param i - source
 * @param supc - target expression (e.g. R some B)
 * @return OWLObjectPropertyAssertionAxiom or null
 */
private OWLObjectPropertyAssertionAxiom trEdge(OWLIndividual i, OWLClassExpression supc) {
	if (supc instanceof OWLObjectSomeValuesFrom) {
		OWLObjectSomeValuesFrom svf = (OWLObjectSomeValuesFrom)supc;
		OWLObjectPropertyExpression p = trTypeLevel(svf.getProperty());
		OWLIndividual j;
		if (svf.getFiller().isAnonymous()) {
			j = anonClassToIndividual(svf.getFiller());
			add(trEdge(j, svf.getFiller()));
		}
		else {
			j = classToIndividual((OWLClass)svf.getFiller());
		}

		OWLObjectPropertyAssertionAxiom e = getOWLDataFactory().getOWLObjectPropertyAssertionAxiom(p, i, j); 
		return e;
	}
	return null;

}
 
Example #4
Source File: ClassExpressionGraphClosureRenderer.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void render(OWLGraphEdge e) {
	OWLObject s = e.getSource();
	OWLClassExpression x = (OWLClassExpression) graph.edgeToTargetExpression(e);
	OWLAxiom ax;
	if (s instanceof OWLClassExpression) {
		ax = graph.getDataFactory().getOWLSubClassOfAxiom((OWLClassExpression)s, x);
	}
	else if (s instanceof OWLIndividual) {
		ax = graph.getDataFactory().getOWLClassAssertionAxiom(x, (OWLIndividual) s);		
	}
	else {
		ax = null;
	}
	if (ax != null) {
		stream.print(ax.toString());
	}
}
 
Example #5
Source File: PhenoSimHQEPreProcessor.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
protected void makeHasPhenotypeInstancesDirect() {
	// x Type has_phenotype some C ==> x Type C
	LOG.info("x Type has_phenotype some C ==> x Type C");
	OWLObjectProperty hasPhenotype = getOWLObjectPropertyViaOBOSuffix(HAS_PHENOTYPE);
	Set<OWLAxiom> rmAxioms = new HashSet<OWLAxiom>();
	Set<OWLAxiom> newAxioms = new HashSet<OWLAxiom>();
	for (OWLClassAssertionAxiom caa : outputOntology.getAxioms(AxiomType.CLASS_ASSERTION)) {
		OWLClassExpression ex = caa.getClassExpression();
		OWLIndividual i = caa.getIndividual();
		if (ex instanceof OWLObjectSomeValuesFrom) {
			OWLObjectSomeValuesFrom svf = (OWLObjectSomeValuesFrom)ex;
			if (svf.getProperty().equals(hasPhenotype)) {
				rmAxioms.add(caa);
				newAxioms.add(getOWLDataFactory().getOWLClassAssertionAxiom(svf.getFiller(), i));
			}

		}
	}
	LOG.info("making instances direct: +"+newAxioms.size()+ " -"+rmAxioms.size());
	addAxiomsToOutput(newAxioms, false);
	removeAxiomsFromOutput(rmAxioms, false);
}
 
Example #6
Source File: AutomaticSimPreProcessor.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void gatherProperties(OWLIndividual ind, int depth) {
	if (visited.contains(ind))
		return;
	if (depth > 1) {
		return;
		// TODO: create property chains
	}
	LOG.info("Gathering props from: "+ind);
	visited.add(ind);
	for (OWLClassExpression x : OwlHelper.getTypes(ind, inputOntology)) {
		gatherProperties(x);
	}
	Map<OWLObjectPropertyExpression, Set<OWLIndividual>> pvs = OwlHelper.getObjectPropertyValues(ind, inputOntology);
	for (OWLObjectPropertyExpression pe : pvs.keySet()) {
		gatherProperties(pe);
		for (OWLIndividual k : pvs.get(pe)) {
			gatherProperties(ind, depth+1);
		}
	}
}
 
Example #7
Source File: ABoxUtils.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public static void randomizeClassAssertions(OWLOntology ont, int num) {
	Set<OWLClassAssertionAxiom> caas = new HashSet<OWLClassAssertionAxiom>();
	Set<OWLClassAssertionAxiom> caasNew = new HashSet<OWLClassAssertionAxiom>();
		Set<OWLNamedIndividual> inds = ont.getIndividualsInSignature(Imports.INCLUDED);
	OWLNamedIndividual[] indArr = (OWLNamedIndividual[]) inds.toArray();
	for (OWLNamedIndividual ind : inds) {
		caas.addAll( ont.getClassAssertionAxioms(ind) );
	}
	for (OWLClassAssertionAxiom caa : caas) {
		OWLIndividual randomIndividual = null;
		caasNew.add(ont.getOWLOntologyManager().getOWLDataFactory().getOWLClassAssertionAxiom(caa.getClassExpression(), 
				randomIndividual));
	}
	ont.getOWLOntologyManager().removeAxioms(ont, caas);
	ont.getOWLOntologyManager().addAxioms(ont, caasNew);
}
 
Example #8
Source File: SimEngine.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public int getCorpusSize() {
	if (corpusSize != null)
		return corpusSize;
	// TODO - option for individuals; for now this is hardcoded
	int n = 0;
	LOG.info("calculating corpus size:");
	for (OWLObject x : graph.getAllOWLObjects()) {
		if (x instanceof OWLIndividual) {
			// exclude individuals that have no attributes from corpus.
			// note: comparisonProperty should be set
			int numAtts = getAttributesForWithRedundant(x).size();
			if (numAtts > 0) {
				//LOG.info("  num atts["+x+"] = "+numAtts);
				n++;
			}
		}
	}
	LOG.info("corpus size:"+n);
	corpusSize = n;
	return n;
}
 
Example #9
Source File: ModelAnnotationSolrDocumentLoader.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private Map<OWLClass, Pair<OWLNamedIndividual, Set<OWLAnnotation>>> findLocations(OWLNamedIndividual mf) {
	Map<OWLClass, Pair<OWLNamedIndividual, Set<OWLAnnotation>>> result = new HashMap<OWLClass, Pair<OWLNamedIndividual,Set<OWLAnnotation>>>();
	Set<OWLObjectPropertyAssertionAxiom> axioms = model.getObjectPropertyAssertionAxioms(mf);
	for (OWLObjectPropertyAssertionAxiom axiom : axioms) {
		if (occursIn.equals(axiom.getProperty()) && mf.equals(axiom.getSubject())) {
			// relevant axiom
			OWLIndividual locationCandidate = axiom.getObject();
			if (locationCandidate.isNamed()) {
				OWLNamedIndividual named = locationCandidate.asOWLNamedIndividual();
				Set<OWLClass> locationTypes = getTypes(named);
				for (OWLClass locationType : locationTypes) {
					result.put(locationType, Pair.of(named, getAnnotations(axiom, named)));
				}
			}
		}
	}
	return result;
}
 
Example #10
Source File: ModelAnnotationSolrDocumentLoader.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private Map<OWLClass, Pair<OWLNamedIndividual, Set<OWLAnnotation>>> findProcesses(OWLNamedIndividual mf) {
	Map<OWLClass, Pair<OWLNamedIndividual, Set<OWLAnnotation>>> result = new HashMap<OWLClass, Pair<OWLNamedIndividual,Set<OWLAnnotation>>>();
	Set<OWLObjectPropertyAssertionAxiom> axioms = model.getObjectPropertyAssertionAxioms(mf);
	for (OWLObjectPropertyAssertionAxiom axiom : axioms) {
		if (partOf.equals(axiom.getProperty()) && mf.equals(axiom.getSubject())) {
			// relevant axiom
			OWLIndividual bpCandidate = axiom.getObject();
			if (bpCandidate.isNamed()) {
				final OWLNamedIndividual named = bpCandidate.asOWLNamedIndividual();
				Set<OWLClass> bpTypes = getTypes(named);
				for (OWLClass bpType : bpTypes) {
					if (bpSet.contains(bpType) == false) {
						continue;
					}
					result.put(bpType, Pair.of(named, getAnnotations(axiom, named)));
				}
			}
		}
	}
	return result;
}
 
Example #11
Source File: OntologySolrLoader.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public SolrInputDocument collect(OWLObject obj, OWLGraphWrapper graph) {

		SolrInputDocument cls_doc = new SolrInputDocument();

		// General for all ontology objects.
		cls_doc.addField("id", graph.getIdentifier(obj));
		cls_doc.addField("label", graph.getLabel(obj));
		cls_doc.addField("description", graph.getDef(obj));
		
		if (obj instanceof OWLClass)
			 collectClass(cls_doc, graph, (OWLClass)obj);
		else if (obj instanceof OWLIndividual)
			 collectIndividual(cls_doc, (OWLIndividual)obj);
		else if (obj instanceof OWLProperty)
			 collectProperty(cls_doc, (OWLProperty)obj);
		return cls_doc; 
	}
 
Example #12
Source File: OWLHandler.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Deprecated
public void deleteFactCommand() throws IOException, OWLOntologyCreationException, OWLOntologyStorageException, UnknownOWLClassException {
	if (isHelp()) {
		info("generates ClassAssertion");
		return;
	}
	OWLOntology ont = resolveOntology(Param.ontology);
	OWLIndividual i = resolveIndividual(Param.individualId);
	OWLIndividual j = resolveIndividual(Param.fillerId);
	OWLObjectProperty p = resolveObjectProperty(Param.propertyId);
	for (OWLObjectPropertyAssertionAxiom ax : ont.getAxioms(AxiomType.OBJECT_PROPERTY_ASSERTION)) {
		if (ax.getSubject().equals(i)) {
			if (p == null || ax.getProperty().equals(p)) {
				if (j == null || ax.getObject().equals(j)) {
					removeAxiom(ont, graph.getDataFactory().getOWLObjectPropertyAssertionAxiom(p, i, j));
				}
			}
		}
	}
	String jsonStr = "";
	response.getWriter().write(jsonStr);
}
 
Example #13
Source File: OWLHandler.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Params: id
 * @throws OWLOntologyCreationException
 * @throws OWLOntologyStorageException
 * @throws IOException
 * @throws OWLParserException
 */
public void getAxiomsCommand() throws OWLOntologyCreationException, OWLOntologyStorageException, IOException, OWLParserException {
	headerOWL();
	boolean direct = getParamAsBoolean(Param.direct, false);
	OWLObject obj = this.resolveEntity();
	LOG.info("finding axioms about: "+obj);
	Set<OWLAxiom> axioms = new HashSet<OWLAxiom>();
	if (obj instanceof OWLClass) {
		axioms.addAll(graph.getSourceOntology().getAxioms((OWLClass)obj, Imports.EXCLUDED));
	}
	if (obj instanceof OWLIndividual) {
		axioms.addAll(graph.getSourceOntology().getAxioms((OWLIndividual)obj, Imports.EXCLUDED));
	}
	if (obj instanceof OWLObjectProperty) {
		axioms.addAll(graph.getSourceOntology().getAxioms((OWLObjectProperty)obj, Imports.EXCLUDED));
	}

	for (OWLAxiom ax : axioms) {
		output(ax);
	}
}
 
Example #14
Source File: AutomaticSimPreProcessor.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void preprocess() {
	
	for (OWLIndividual ind : inputOntology.getIndividualsInSignature(Imports.INCLUDED)) {
		gatherProperties(ind);
	}
	
	for (OWLObjectProperty p : viewProperties) {
		createPropertyView(p);
	}
	flush();
}
 
Example #15
Source File: OWLGraphWrapperEdges.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * return all individuals i where x is reachable from i
 * @param x
 * @return set of individual {@link OWLObject}s
 */
public Set<OWLObject> getIndividualDescendants(OWLObject x) {
	Set<OWLObject> descs = new HashSet<OWLObject>();
	for (OWLGraphEdge e : getIncomingEdgesClosure(x)) {
		OWLObject s = e.getSource();
		if (s instanceof OWLIndividual)
			descs.add(s);
	}
	return descs;
}
 
Example #16
Source File: OwlHelper.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static Map<OWLObjectPropertyExpression, Set<OWLIndividual>> getObjectPropertyValues(OWLIndividual i, OWLOntology ont) {
	Set<OWLObjectPropertyAssertionAxiom> axioms = ont.getObjectPropertyAssertionAxioms(i);
	Map<OWLObjectPropertyExpression, Set<OWLIndividual>> result = new HashMap<>();
	for(OWLObjectPropertyAssertionAxiom ax : axioms) {
		Set<OWLIndividual> inds = result.get(ax.getProperty());
		if (inds == null) {
			inds = new HashSet<>();
			result.put(ax.getProperty(), inds);
		}
		inds.add(ax.getObject());
	}
	return result;
}
 
Example #17
Source File: OwlHelper.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static Set<OWLClassExpression> getTypes(OWLIndividual i, OWLOntology ont) {
	Set<OWLClassExpression> types;
	if (ont != null && i != null && i.isNamed()) {
		types = getTypes(i.asOWLNamedIndividual(), ont);
	}
	else {
		types = Collections.emptySet();
	}
	return types;
}
 
Example #18
Source File: OWLInAboxTranslator.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Translates an anonymous class expression C to an ABox shadow representation C'
 * 
 * If isMaterialize is true, a IRI is created for C' - otherwise it is anonymous
 * 
 * @param owlClassExpression
 * @param isMaterialize
 * @return ABox shadow of input class
 */
private OWLIndividual anonClassToIndividual(OWLClassExpression owlClassExpression, boolean isMaterialize) {
	if (isMaterialize) {
		UUID uuid = UUID.randomUUID();
		//UUID uuid = UUID.fromString(owlClassExpression.toString());
		OWLNamedIndividual i = getOWLDataFactory().getOWLNamedIndividual(IRI.create("urn:uuid:"+uuid.toString()));
		instances.add(i);
		return i;
	}
	else 
		return getOWLDataFactory().getOWLAnonymousIndividual();
}
 
Example #19
Source File: OWLGraphWrapperEdges.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Finds all edges between an instance i and he given class c.
 * <p>
 * this includes inferred class assertions, as well as chains such as
 * <p>
 * i has_part j, j inst_of k, k part_of some c
 * 
 * @param c owlClass
 * @return all edges in closure between an instance and owlClass
 */
public Set<OWLGraphEdge> getInstanceChainsFromClosure(OWLClass c) {
	Set<OWLGraphEdge> edges = new OWLGraphEdgeSet();
	for (OWLOntology o : getAllOntologies()) {
		// iterate through all individuals; sequential scan may be slow for
		// large knowledge bases
		for (OWLIndividual in : o.getIndividualsInSignature()) {
		    edges.addAll(getEdgesBetween(in, c));
		}
	}
	return edges;
}
 
Example #20
Source File: SimpleOntologyValues.java    From mobi with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * .
 */
public static Individual mobiIndividual(OWLIndividual owlapiIndividual) {
    if (owlapiIndividual == null || !owlapiIndividual.isNamed()) {
        return null;
    }
    org.semanticweb.owlapi.model.IRI owlapiIri = owlapiIndividual.asOWLNamedIndividual().getIRI();
    IRI mobiIri = mobiIRI(owlapiIri);
    return new SimpleIndividual(mobiIri);
}
 
Example #21
Source File: CAROLCSTest.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test
public void testConvertXPs() throws Exception {
	ParserWrapper pw = new ParserWrapper();
	OWLGraphWrapper g =
		pw.parseToOWLGraph(getResourceIRIString("lcstest1.owl"));
	OWLOntology ont = g.getSourceOntology();
	OWLObject o2 = g.getOWLObject("http://example.org#o2");

	LOG.debug("getting ancestors for: "+o2);
	for (OWLGraphEdge e : g.getOutgoingEdgesClosure(o2)) {
		LOG.debug(e);
	}
	for (OWLClass c : ont.getClassesInSignature()) {
		LOG.debug("getting individuals for "+c+" "+g.getLabel(c));
		for (OWLIndividual i : g.getInstancesFromClosure(c)) {
			LOG.debug("  "+i);
		}
	}

	/*
	for (OWLClass c : ont.getClassesInSignature()) {
		System.out.println("c="+c+" "+g.getLabel(c));
		for (OWLGraphEdge e : g.getOutgoingEdgesClosure(c)) {
			System.out.println("CLOSURE: "+e);
		}
	}
	*/
	/*
	OWLObject s = g.getOWLObjectByIdentifier("CARO:0000014");
	OWLObject t = g.getOWLObjectByIdentifier("CARO:0000000");
	assertTrue(g.getEdgesBetween(s, t).size() > 0);
	*/
}
 
Example #22
Source File: LegoTools.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public List<LegoNode> createLegoNodes(Collection<OWLNamedIndividual> individuals) throws UnExpectedStructureException {
	List<LegoNode> nodes = new ArrayList<LegoNode>(individuals.size());
	Set<OWLOntology> ontologies = new HashSet<OWLOntology>(graph.getAllOntologies());
	for (OWLNamedIndividual individual : individuals) {
		Set<OWLClassAssertionAxiom> axioms = getClassAxioms(individual, ontologies);
		final LegoNode node = createNode(individual, axioms, ontologies);
		if (node != null) {
			// links
			List<LegoLink> links = new ArrayList<LegoLink>();
			Set<OWLObjectPropertyAssertionAxiom> propertyAxioms = getPropertyAxioms(individual, ontologies);
			for (OWLObjectPropertyAssertionAxiom propertyAxiom : propertyAxioms) {
				OWLIndividual object = propertyAxiom.getObject();
				if (object instanceof OWLNamedIndividual == false) {
					throw new UnExpectedStructureException("Expected a named individual for a link: "+propertyAxiom);
				}
				OWLNamedIndividual namedTarget = (OWLNamedIndividual) object;
				OWLObjectPropertyExpression property = propertyAxiom.getProperty();
				LegoLink link = new LegoLink(individual, namedTarget, property);
				LegoMetadata.extractMetadata(link, propertyAxiom);
				links.add(link);
			}
			if (!links.isEmpty()) {
				node.setLinks(links);
			}
			
			nodes.add(node);
		}
	}
	
	return nodes;
}
 
Example #23
Source File: LegoUnitTools.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private OWLClass getType(OWLIndividual individual) {
	OWLClass type = null;
	if (individual.isNamed()) {
		Set<OWLClass> set = reasoner.getTypes(individual.asOWLNamedIndividual(), true).getFlattened();
		if (set.size() == 1) {
			OWLClass cls = set.iterator().next();
			if (cls.isBuiltIn() == false) {
				type = cls;
			}
		}
	}
	return type;
}
 
Example #24
Source File: AbstractElkObjectConverter.java    From elk-reasoner with Apache License 2.0 5 votes vote down vote up
Set<OWLIndividual> toIndividualSet(List<? extends ElkIndividual> input) {
	Set<OWLIndividual> result = new HashSet<OWLIndividual>(input.size());
	for (ElkIndividual next : input) {
		result.add(convert(next));
	}
	return result;
}
 
Example #25
Source File: ElkObjectOneOfWrap.java    From elk-reasoner with Apache License 2.0 5 votes vote down vote up
@Override
public List<? extends ElkIndividual> getIndividuals() {
	List<ElkIndividual> result = new ArrayList<ElkIndividual>();
	for (OWLIndividual ce : this.owlObject.getIndividuals()) {
		result.add(converter.convert(ce));
	}
	return result;
}
 
Example #26
Source File: GraphOwlVisitor.java    From SciGraph with Apache License 2.0 5 votes vote down vote up
@Override
public Void visit(OWLSameIndividualAxiom axiom) {
  List<Long> nodes = transform(axiom.getIndividualsAsList(), new Function<OWLIndividual, Long>() {
    @Override
    public Long apply(OWLIndividual individual) {
      return getOrCreateNode(getIri(individual));
    }
  });
  getOrCreateRelationshipPairwise(nodes, OwlRelationships.OWL_SAME_AS);
  return null;
}
 
Example #27
Source File: OWLHandler.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Deprecated
public void assertTypeCommand() throws IOException, OWLOntologyCreationException, OWLOntologyStorageException, UnknownOWLClassException {
	if (isHelp()) {
		info("generates ClassAssertion");
		return;
	}
	OWLOntology ont = resolveOntology(Param.ontology);
	OWLClass c = resolveClass(Param.classId);
	OWLIndividual i = resolveIndividual(Param.individualId);
	addAxiom(ont, graph.getDataFactory().getOWLClassAssertionAxiom(c, i));
	String jsonStr = "";
	response.getWriter().write(jsonStr);
}
 
Example #28
Source File: GraphOwlVisitor.java    From SciGraph with Apache License 2.0 5 votes vote down vote up
@Override
public Void visit(OWLDifferentIndividualsAxiom axiom) {
  List<Long> nodes = transform(axiom.getIndividualsAsList(), new Function<OWLIndividual, Long>() {
    @Override
    public Long apply(OWLIndividual individual) {
      return getOrCreateNode(getIri(individual));
    }
  });
  getOrCreateRelationshipPairwise(nodes, OwlRelationships.OWL_DIFFERENT_FROM);
  return null;
}
 
Example #29
Source File: ElkSameIndividualAxiomWrap.java    From elk-reasoner with Apache License 2.0 5 votes vote down vote up
@Override
public List<? extends ElkIndividual> getIndividuals() {
	List<ElkIndividual> result = new ArrayList<ElkIndividual>();
	for (OWLIndividual ind : this.owlObject.getIndividuals()) {
		result.add(converter.convert(ind));
	}
	return result;
}
 
Example #30
Source File: SimEngine.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public int getFrequency(OWLObject obj) {
	// TODO - option for individuals; for now this is hardcoded
	int n = 0;
	for (OWLObject x : graph.getDescendants(obj)) {
		if (x instanceof OWLIndividual) {
			n++;
		}
	}
	LOG.info("descendants of "+obj+" #= "+n);

	return n;
	//return graph.getDescendants(obj).size();	
}