org.semanticweb.owlapi.model.OWLNamedIndividual Java Examples

The following examples show how to use org.semanticweb.owlapi.model.OWLNamedIndividual. 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: SimCommandRunner.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * performs all by all individual comparison
 * @param opts 
 * @throws UnknownOWLClassException 
 */
public void runOwlSim(Opts opts) throws UnknownOWLClassException {
	sos.setSimProperties(simProperties);
	OWLPrettyPrinter owlpp = getPrettyPrinter();
	if (opts.nextEq("-q")) {
		runOwlSimOnQuery(opts, opts.nextOpt());
		return;
	}
	Set<OWLNamedIndividual> insts = pproc.getOutputOntology().getIndividualsInSignature();
	LOG.info("All by all for "+insts.size()+" individuals");
	for (OWLNamedIndividual i : insts) {
		for (OWLNamedIndividual j : insts) {
			// similarity is symmetrical
			if (isComparable(i,j)) {
				showSim(i,j, owlpp);
			}
		}
	}
	LOG.info("FINISHED All by all for "+insts.size()+" individuals");
}
 
Example #2
Source File: SimpleOwlSim.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void createElementAttributeMapFromOntology() {
	elementToAttributesMap = new HashMap<OWLNamedIndividual,Set<OWLClass>>();
	Set<OWLClass> allTypes = new HashSet<OWLClass>();
	for (OWLNamedIndividual e : sourceOntology.getIndividualsInSignature(Imports.INCLUDED)) {

		// The attribute classes for an individual are the direct inferred
		// named types. We assume that grouping classes have already been
		// generated.
		// if they have not then the types may be as general as {Thing}
		Set<OWLClass> types = getReasoner().getTypes(e, true).getFlattened();
		allTypes.addAll(addElement(e, types));
	}
	// need to materialize as classes...
	LOG.info("Using " + allTypes.size()
			+ " attribute classes, based on individuals: "
			+ sourceOntology.getIndividualsInSignature(Imports.INCLUDED).size());
	cachedAttributeClasses = allTypes;
}
 
Example #3
Source File: FastOwlSim.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public List<ClassCount> getCoAnnotatedClassesForIndividual(OWLNamedIndividual i, int matchCutoff) throws Exception {

		//findMatches
		List<ElementPairScores> matches = this.findMatches(i,null);
		//remove exact match
		
		int exactMatchIndex = -1;
		for (int m=0; m<matches.size(); m++) { 
			ElementPairScores eps = matches.get(m);
			if (eps.j.equals(i)) {
				exactMatchIndex = m;
			}
		}
		if (exactMatchIndex > -1) {
			LOG.info("Removed exact match of individual "+matches.get(exactMatchIndex).j.toStringID());
			matches.remove(exactMatchIndex);
		}
		
		List<ClassCount> coannotationSet = getCoAnnotatedClassesForMatches(matches, getAttributesForElement(i));

		return coannotationSet;
	}
 
Example #4
Source File: AbstractOWLSimTest.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
protected void showSim(OWLNamedIndividual i, OWLNamedIndividual j) throws Exception {
	if (i==j) return;
	double s = owlsim.getElementJaccardSimilarity(i, j);
	if (s > 0.1) {
		LOG.info("SimJ( "+i+" , "+j+" ) = "+s);

		//ScoreAttributeSetPair maxic = owlsim.getSimilarityMaxIC(i, j);
		//LOG.info("MaxIC( "+i+" , "+j+" ) = "+maxic.score+" "+show(maxic.attributeClassSet));

		//ScoreAttributeSetPair bma = owlsim.getSimilarityBestMatchAverageAsym(i, j);
		//LOG.info("BMAasym( "+i+" , "+j+" ) = "+bma.score+" "+show(bma.attributeClassSet));
		ElementPairScores scores;
		try {
			scores = owlsim.getGroupwiseSimilarity(i,j);
			renderer.printPairScores(scores);
		} catch (CutoffException e) {
			LOG.info(e.getMessage());
		}
	}

}
 
Example #5
Source File: ModelAnnotationSolrDocumentLoader.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private OWLNamedIndividual findEvidenceIndividual(OWLAnnotationValue value) {
	return value.accept(new OWLAnnotationValueVisitorEx<OWLNamedIndividual>() {

		@Override
		public OWLNamedIndividual visit(final IRI iri) {
			OWLNamedIndividual i = null;
			for(OWLNamedIndividual current : model.getIndividualsInSignature()) {
				if (current.getIRI().equals(iri)) {
					i = current;
					break;
				}
			}
			return i;
		}

		@Override
		public OWLNamedIndividual visit(OWLAnonymousIndividual individual) {
			return null;
		}

		@Override
		public OWLNamedIndividual visit(OWLLiteral literal) {
			return null;
		}
	});
}
 
Example #6
Source File: FastOwlSim.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public List<ElementPairScores> findMatches(Set<OWLClass> atts, String targetIdSpace, double minSimJPct, double minMaxIC) throws Exception {
	Set<OWLNamedIndividual> candidateTargetSet;
	
	if (targetIdSpace == null) { 
		candidateTargetSet = getAllElements();
	}
	else {
		candidateTargetSet = new HashSet<OWLNamedIndividual>();
		for (OWLNamedIndividual j : getAllElements()) {
			if (j.getIRI().toString().contains("/"+targetIdSpace+"_")) {
				candidateTargetSet.add(j);
			}
			
		}
	}
	return findMatchesWithin(atts, candidateTargetSet, minSimJPct, minMaxIC);
}
 
Example #7
Source File: FastOwlSim.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private EWAHCompressedBitmap getElementsForAttributeAsBitmao(OWLClass c) throws UnknownOWLClassException {
	if (classToElementBitmapMap == null)
		classToElementBitmapMap = new HashMap<OWLClass,EWAHCompressedBitmap>();
	if (classToElementBitmapMap.containsKey(c)) {
		return classToElementBitmapMap.get(c);
	}
	Set<OWLNamedIndividual> inds = getElementsForAttribute(c);
	Set<Integer> indInts = new HashSet<Integer>();
	makeIndividualIndex();
	for (OWLNamedIndividual i : inds) {
		indInts.add(individualIndex.get(i));
	}
	EWAHCompressedBitmap bm = convertIntsToBitmap(indInts);
	classToElementBitmapMap.put(c, bm);
	return bm;
}
 
Example #8
Source File: FastOwlSim.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public ScoreAttributeSetPair getSimilarityMaxIC(OWLNamedIndividual i,
		OWLNamedIndividual j) throws UnknownOWLClassException {

	Set<Node<OWLClass>> atts = getNamedCommonSubsumers(i,j);

	ScoreAttributeSetPair best = new ScoreAttributeSetPair(0.0);
	for (Node<OWLClass> n : atts) {
		OWLClass c = getDeterministicRepresentative(n);
		Double ic = getInformationContentForAttribute(c);
		if (Math.abs(ic - best.score) < 0.000001) {
			// tie for best attribute
			best.addAttributeClass(c);
		}
		if (ic > best.score) {
			best = new ScoreAttributeSetPair(ic, c);
		}
	}
	return best;
}
 
Example #9
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(OWLNamedIndividual i, OWLOntology ont) {
	Set<OWLClassExpression> types;
	if (i != null && ont != null) {
		types = new HashSet<>();
		for (OWLClassAssertionAxiom axiom : ont.getClassAssertionAxioms(i)) {
			types.add(axiom.getClassExpression());
		}
	}
	else {
		types = Collections.emptySet();
	}
	return types;
}
 
Example #10
Source File: SimpleOwlSim.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public Set<OWLNamedIndividual> getElementsForAttribute(OWLClass c) {
	Set<OWLClass> subclasses = getReasoner().getSubClasses(c, false)
			.getFlattened();
	subclasses.add(c);
	Set<OWLNamedIndividual> elts = new HashSet<OWLNamedIndividual>();
	for (OWLClass sc : subclasses) {
		if (attributeToElementsMap.containsKey(sc)) {
			elts.addAll(attributeToElementsMap.get(sc));
		}
	}
	return elts;
}
 
Example #11
Source File: OldSimpleOwlSim.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public Set<Node<OWLClass>> getNamedSubsumers(OWLNamedIndividual a) {
	Set<Node<OWLClass>> nodes = new HashSet<Node<OWLClass>>();
	// for now we do not use reasoners for the first step (Elk does not support ABoxes)
	for (OWLClass c: this.getAttributesForElement(a)) {
		nodes.addAll(getReasoner().getSuperClasses(c, false).getNodes());
	}
	return nodes;
}
 
Example #12
Source File: FormattedRenderer.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void printAttributeSimWithIndividuals(AttributesSimScores simScores,
		OWLPrettyPrinter owlpp, OWLGraphWrapper g, OWLNamedIndividual i,
		OWLNamedIndividual j) {
	// TODO Auto-generated method stub

}
 
Example #13
Source File: FastOwlSim.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public double getElementGraphInformationContentSimilarity(
		OWLNamedIndividual i, OWLNamedIndividual j) throws UnknownOWLClassException {
	// TODO - optimize
	long t = System.currentTimeMillis();
	EWAHCompressedBitmap bmc = ancsBitmapCachedModifiable(i);
	EWAHCompressedBitmap bmd = ancsBitmapCachedModifiable(j);
	EWAHCompressedBitmap cad = bmc.and(bmd);
	EWAHCompressedBitmap cud = bmc.or(bmd);


	//Set<Node<OWLClass>> ci = getNamedCommonSubsumers(i, j);
	//Set<Node<OWLClass>> cu = getNamedUnionSubsumers(i, j);
	double sumICboth = 0;
	double sumICunion = 0;

	// faster than translating to integer list
	IntIterator it = cud.intIterator();
	while (it.hasNext()) {
		int x = it.next();
		double ic = getInformationContentForAttribute(x);
		// TODO - we can avoid doing this twice by using xor in the bitmap
		sumICunion += ic;

		if (cad.get(x)) {
			sumICboth += ic;
		}
	}

	totalTimeGIC += tdelta(t);
	this.totalCallsGIC++;

	return sumICboth / sumICunion;
}
 
Example #14
Source File: FastOwlSim.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public Set<Node<OWLClass>> getNamedCommonSubsumers(OWLNamedIndividual i,
		OWLNamedIndividual j) throws UnknownOWLClassException {
	EWAHCompressedBitmap bmc = ancsBitmapCachedModifiable(i);
	EWAHCompressedBitmap bmd = ancsBitmapCachedModifiable(j);
	EWAHCompressedBitmap cad = bmc.and(bmd);
	Set<Node<OWLClass>> nodes = new HashSet<Node<OWLClass>>();
	for (int ix : cad.toArray()) {
		OWLClassNode node = new OWLClassNode(classArray[ix]);
		nodes.add(node);
	}
	return nodes;
}
 
Example #15
Source File: LazyExpressionMaterializingReasoner.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public NodeSet<OWLNamedIndividual> getInstances(OWLClassExpression ce,
		boolean direct) throws InconsistentOntologyException,
		ClassExpressionNotInProfileException, FreshEntitiesException,
		ReasonerInterruptedException, TimeOutException {
	if (ce.isAnonymous()) {
		OWLClass c = materializeExpression(ce);
		return getInstances(c, direct);
	}
	return getWrappedReasoner().getInstances(ce, direct);
}
 
Example #16
Source File: ModelAnnotationSolrDocumentLoader.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private Set<OWLAnnotation> getAnnotations(OWLAxiom ax, OWLNamedIndividual i) {
	Set<OWLAnnotation> all = new HashSet<OWLAnnotation>();
	if (ax != null) {
		all.addAll(ax.getAnnotations());
	}
	if (i != null) {
		Set<OWLAnnotationAssertionAxiom> aaas = model.getAnnotationAssertionAxioms(i.getIRI());
		for(OWLAnnotationAssertionAxiom aaa : aaas) {
			all.add(aaa.getAnnotation());
		}
	}
	return all;
}
 
Example #17
Source File: AbstractSimPreProcessor.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Deprecated
public Set<OWLClassExpression> getDirectAttributeClassExpressions() {
	Set<OWLClassExpression> types = new HashSet<OWLClassExpression>();
	for (OWLNamedIndividual ind : inputOntology.getIndividualsInSignature(Imports.INCLUDED)) {
		types.addAll(OwlHelper.getTypes(ind, inputOntology));
	}
	LOG.info("Num attribute expressions = "+types.size());
	return types;
}
 
Example #18
Source File: SimpleOwlSim.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public Set<Node<OWLClass>> getNamedCommonSubsumers(OWLNamedIndividual a,
		OWLNamedIndividual b) {
	// we don't cache this as we assume it will be called at most once
	Set<Node<OWLClass>> nodes = getInferredAttributes(a);
	nodes.retainAll(getInferredAttributes(b));
	return nodes;
}
 
Example #19
Source File: ComplexAnnotationSolrDocumentLoader.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public ComplexAnnotationSolrDocumentLoader(String url, OWLGraphWrapper g, OWLReasoner r, Set<OWLNamedIndividual> individuals, Set<OWLAnnotation> modelAnnotations, String agID, String agLabel, String agURL) throws MalformedURLException {
	super(url);
	//setGraph(g);
	current_doc_number = 0;
	currentGraph = g;
	currentReasoner  = r;
	legoIndividuals = individuals;
	this.modelAnnotations = modelAnnotations;
	currentGroupID = agID;
	currentGroupLabel = agLabel;
	currentGroupURL = agURL;
}
 
Example #20
Source File: Sim2CommandRunner.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Prints a tab-delimited report of the IC measures for each annotation (class)
 * made to each instance.  Report could be used for external statistical
 * analysis.
 * instance ID | class ID | IC
 * @param opts
 * @throws Exception
 */
@CLIMethod("--show-instance-IC-values")
public void instanceICValues(Opts opts) throws Exception {
	try {
		loadProperties(opts);
		if (owlsim == null) {
			owlsim = getOwlSimFactory().createOwlSim(g.getSourceOntology());
			owlsim.createElementAttributeMapFromOntology();
		}
		Set<OWLNamedIndividual> insts = owlsim.getAllElements();
		LOG.info("Writing IC values for all " + insts.size() + " annotations.");

		for (OWLNamedIndividual i : insts) {
			for (OWLClass c : owlsim.getAttributesForElement(i)) {
				resultOutStream.print(g.getIdentifier(i));
				resultOutStream.print("\t");
				resultOutStream.print(g.getIdentifier(c));
				resultOutStream.print("\t");
				resultOutStream.print(owlsim.getInformationContentForAttribute(c));
				resultOutStream.println();
				resultOutStream.flush();
			}
		}

	} finally {
		IOUtils.closeQuietly(resultOutStream);
	}

}
 
Example #21
Source File: GraphReasoner.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public Set<OWLLiteral> getDataPropertyValues(OWLNamedIndividual ind,
		OWLDataProperty pe) throws InconsistentOntologyException,
		FreshEntitiesException, ReasonerInterruptedException,
		TimeOutException {
	// TODO Auto-generated method stub
	return null;
}
 
Example #22
Source File: BasicOWLSimTest.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test
public void testBasicSim() throws Exception {
	ParserWrapper pw = new ParserWrapper();
	sourceOntol = pw.parseOBO(getResource("sim/mp-subset-1.obo").getAbsolutePath());
	g =  new OWLGraphWrapper(sourceOntol);
	parseAssociations(getResource("sim/mgi-gene2mp-subset-1.tbl"), g);
	setOutput("target/basic-owlsim-test.out");
	
	owlpp = new OWLPrettyPrinter(g);

	// assume buffering
	OWLReasoner reasoner = new ElkReasonerFactory().createReasoner(sourceOntol);
	try {

		this.createOwlSim();
		owlsim.createElementAttributeMapFromOntology();
		
		//sos.saveOntology("/tmp/z.owl");

		reasoner.flush();
		for (OWLNamedIndividual i : sourceOntol.getIndividualsInSignature()) {
			for (OWLNamedIndividual j : sourceOntol.getIndividualsInSignature()) {
				showSim(i,j);
			}
		}
	}
	finally {
		reasoner.dispose();
	}
}
 
Example #23
Source File: DescriptionTreeSimilarity.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private OWLClassExpression makeClassExpression(OWLObject x) {
	if (x instanceof OWLClassExpression)
		return (OWLClassExpression) x;
	else if (x instanceof OWLNamedIndividual) {
		// TODO - move this to graphwrapper
		Set<OWLNamedIndividual> nis = new HashSet<OWLNamedIndividual>();
		nis.add((OWLNamedIndividual) x);
		return graph.getDataFactory().getOWLObjectOneOf(nis);
	}
	else {
		System.err.println("cannot make CE from:"+x);
	}
	return null;
}
 
Example #24
Source File: FastOwlSim.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
protected void populateSimilarityMatrix(
		OWLNamedIndividual i, OWLNamedIndividual j,
		ElementPairScores ijscores) throws UnknownOWLClassException, NoElementAttributeMapException {

	/*
	EWAHCompressedBitmap bmc = ancsBitmapCachedModifiable(i);
	EWAHCompressedBitmap bmd = ancsBitmapCachedModifiable(j);
	EWAHCompressedBitmap cad = bmc.and(bmd);
	EWAHCompressedBitmap cud = bmc.or(bmd);
	Set<Node<OWLClass>> nodes = new HashSet<Node<OWLClass>>();
	for (int ix : cad.toArray()) {
		OWLClassNode node = new OWLClassNode(classArray[ix]);
		nodes.add(node);
	}
	 */

	/*
	ijscores.simGIC = getElementGraphInformationContentSimilarity(i, j);
	ijscores.asymmetricSimGIC = getAsymmetricElementGraphInformationContentSimilarity(i, j);
	ijscores.inverseAsymmetricSimGIC = getAsymmetricElementGraphInformationContentSimilarity(j, i);
	 */

	ijscores.simjScore = getElementJaccardSimilarity(i, j);

	if (ijscores.simjScore == null || ijscores.simjScore.isNaN()) {
		//the elementattributemap probably hasn't been populated.
		//log an error and exit.
		throw new NoElementAttributeMapException();
	}


	ijscores.asymmetricSimjScore = 
			getAsymmetricElementJaccardSimilarity(i, j);
	ijscores.inverseAsymmetricSimjScore =
			getAsymmetricElementJaccardSimilarity(j, i);

	Vector<OWLClass> cs = new Vector<OWLClass>(getAttributesForElement(i));
	Vector<OWLClass> ds = new Vector<OWLClass>(getAttributesForElement(j));
	populateSimilarityMatrix(cs, ds, ijscores);
}
 
Example #25
Source File: Sim2CommandRunner.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Iterates through all individuals, generating similarity calculations for
 * each of its attributes (ontology classes). As opposed to
 * 
 * {@link #attributeAllByAll }, which outputs the comparison of any two attributes only
 *                     ever once, this method will necessarily output the
 *                     pairwise-comparison repeatedly, if the same two
 *                     attributes belong to two different sets of individuals.
 * 
 * @param opts
 * @throws UnknownOWLClassException 
 */
public void attributeSimilarityAllByAllPairwise(Opts opts) throws UnknownOWLClassException {
	try {
		owlsim.setSimProperties(simProperties);
		Set<OWLNamedIndividual> insts = pproc.getOutputOntology()
				.getIndividualsInSignature();

		LOG.info("Pairwise attribute comparison for " + insts.size()
				+ " individuals");

		//set the renderer
		SimResultRenderer renderer = setRenderer();

		renderer.printComment("All-by-all pairwise attribute similarity");

		int attrCounter = 0;
		int comparableCounter = 0;
		for (OWLNamedIndividual i : insts) {
			for (OWLNamedIndividual j : insts) {
				if (isComparable(i, j)) {
					comparableCounter += 1;
					attributeSimilarityByPair(i, j);
					attrCounter += (owlsim.getAttributesForElement(i).size() + owlsim
							.getAttributesForElement(j).size());
				} else {
					LOG.info("skipping (not comparable): " + i + " + " + j);
				}
			}
		}

		LOG.info("FINISHED Pairwise All by all for " + comparableCounter
				+ " comparable individuals containing " + attrCounter + " classes");
		// LOG.info("Number of pairs filtered as they scored beneath threshold: "+this.numberOfPairsFiltered);
	} finally {
		IOUtils.closeQuietly(resultOutStream);
	}
}
 
Example #26
Source File: LegoUnitTools.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private Set<OWLClassAssertionAxiom> getClassAxioms(OWLNamedIndividual individual) {
	Set<OWLClassAssertionAxiom> allAxioms = new HashSet<OWLClassAssertionAxiom>();
	for(OWLOntology o : graph.getAllOntologies()) {
		allAxioms.addAll(o.getClassAssertionAxioms(individual));
	}
	return allAxioms;
}
 
Example #27
Source File: DelimitedLineRenderer.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
protected void renderAttScoreWithIndividuals(String label, double score, OWLClass a, OWLClass b, OWLNamedIndividual i, OWLNamedIndividual j, OWLGraphWrapper g, OWLPrettyPrinter owlpp) {
	resultOutStream.print(label);
	resultOutStream.print(separator);
	resultOutStream.print(renderPair(i,j, owlpp));
	resultOutStream.print(separator);
	resultOutStream.print(owlpp.render(a));
	resultOutStream.print(separator);
	resultOutStream.print(owlpp.render(b));
	resultOutStream.print(separator);
	resultOutStream.print(doubleRenderer.format(score));
	resultOutStream.print(separator);
	resultOutStream.println();
}
 
Example #28
Source File: BigFastOwlSimTest.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void ixi(int size) throws Exception {
	Set<OWLNamedIndividual> all = owlsim.getAllElements();
	Set<OWLNamedIndividual> iset = new HashSet<OWLNamedIndividual>();
	int i=0;
	for (OWLNamedIndividual c : all) {
		i++;
		if (i>size)
			break;
		iset.add(c);
	}
	ixi(iset, iset);
}
 
Example #29
Source File: AbstractOwlSim.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * @param c
 * @param d
 * @return P(c|d) = P(c^d|d)
 * @throws UnknownOWLClassException 
 */
@Override
public double getConditionalProbability(OWLClass c, OWLClass d) throws UnknownOWLClassException {
	Set<OWLNamedIndividual> cis = this.getElementsForAttribute(c);
	Set<OWLNamedIndividual> dis = this.getElementsForAttribute(d);
	cis.retainAll(dis);
	return cis.size() / (double) dis.size();
}
 
Example #30
Source File: ConjunctiveSetInformationContentRatioSimilarity.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
protected void translateResultsToOWLAxioms(String id, OWLNamedIndividual result, Set<OWLAxiom> axioms) {
	OWLDataFactory df = simEngine.getGraph().getDataFactory();
	
	// declare a named class for the LCS and make this equivalent to the anonymous expression
	OWLClass namedLCS = df.getOWLClass(IRI.create(id+"_LCS"));
	axioms.add(df.getOWLAnnotationAssertionAxiom(df.getOWLAnnotationProperty(OWLRDFVocabulary.RDFS_LABEL.getIRI()),
			namedLCS.getIRI(), 
			df.getOWLLiteral("LCS of "+simEngine.label(a)+" and "+simEngine.label(b))));
	axioms.add(df.getOWLEquivalentClassesAxiom(namedLCS, getLCS()));

	// link the similarity object to the named LCS
	OWLAnnotationProperty lcsp = df.getOWLAnnotationProperty(annotationIRI("has_least_common_subsumer"));
	axioms.add(df.getOWLAnnotationAssertionAxiom(lcsp, result.getIRI(), namedLCS.getIRI()));
}