Java Code Examples for com.googlecode.javaewah.EWAHCompressedBitmap#toArray()

The following examples show how to use com.googlecode.javaewah.EWAHCompressedBitmap#toArray() . 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: SimSpeedTest.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Test
@Ignore("This test requires an external resource. This can lead to false positive failures.")
public void bitmapTest() throws OWLOntologyCreationException, OBOFormatParserException, IOException {
	Set<Integer> ixs = new HashSet<Integer>();
	ixs.add(99);
	ixs.add(2000);
	ixs.add(7777);
	EWAHCompressedBitmap bm = bm(ixs);
	Set<Integer> ixs2 = new HashSet<Integer>();
	for (int i : bm.toArray()) {
		System.out.println(i);
		ixs.add(i);
	}
	assert(ixs.equals(ixs2));
	
}
 
Example 2
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(OWLClass c, OWLClass d) throws UnknownOWLClassException {
	EWAHCompressedBitmap bmc = ancsBitmapCachedModifiable(c);
	EWAHCompressedBitmap bmd = ancsBitmapCachedModifiable(d);
	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 3
Source File: FastOwlSim.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private Set<Node<OWLClass>> getNamedCommonSubsumers(int cix, int dix) throws UnknownOWLClassException {
	EWAHCompressedBitmap bmc = ancsBitmapCachedModifiable(cix);
	EWAHCompressedBitmap bmd = ancsBitmapCachedModifiable(dix);
	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 4
Source File: FastOwlSim.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public Set<Node<OWLClass>> getNamedUnionSubsumers(OWLClass c, OWLClass d) throws UnknownOWLClassException {
	EWAHCompressedBitmap bmc = ancsBitmapCachedModifiable(c);
	EWAHCompressedBitmap bmd = ancsBitmapCachedModifiable(d);
	EWAHCompressedBitmap cud = bmc.or(bmd);
	Set<Node<OWLClass>> nodes = new HashSet<Node<OWLClass>>();
	for (int ix : cud.toArray()) {
		OWLClassNode node = new OWLClassNode(classArray[ix]);
		nodes.add(node);
	}
	return nodes;
}
 
Example 5
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 6
Source File: FastOwlSim.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private Set<Node<OWLClass>> getNamedUnionSubsumers(OWLNamedIndividual i,
		OWLNamedIndividual j) throws UnknownOWLClassException {
	EWAHCompressedBitmap bmc = ancsBitmapCachedModifiable(i);
	EWAHCompressedBitmap bmd = ancsBitmapCachedModifiable(j);
	EWAHCompressedBitmap cad = 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);
	}
	return nodes;
}
 
Example 7
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>> getNamedLowestCommonSubsumers(OWLClass c,
		OWLClass d) throws UnknownOWLClassException {
	EWAHCompressedBitmap cad = getNamedLowestCommonSubsumersAsBitmap(c, d);
	Set<Node<OWLClass>> nodes = new HashSet<Node<OWLClass>>();
	// TODO - optimize this & ensure all elements of an equivalence set are included
	for (int ix : cad.toArray()) {
		OWLClassNode node = new OWLClassNode(classArray[ix]);
		nodes.add(node);
	}
	return nodes;

}
 
Example 8
Source File: FastOwlSim.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private Set<Node<OWLClass>> getNamedLowestCommonSubsumers(int cix, int dix) throws UnknownOWLClassException {
	EWAHCompressedBitmap cad = getNamedLowestCommonSubsumersAsBitmap(cix, dix);
	Set<Node<OWLClass>> nodes = new HashSet<Node<OWLClass>>();
	// TODO - optimize this & ensure all elements of an equivalence set are included
	for (int ix : cad.toArray()) {
		OWLClassNode node = new OWLClassNode(classArray[ix]);
		nodes.add(node);
	}
	return nodes;

}
 
Example 9
Source File: FastOwlSim.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private EWAHCompressedBitmap getNamedLowestCommonSubsumersAsBitmap(OWLClass c,
		OWLClass d) throws UnknownOWLClassException  {
	EWAHCompressedBitmap bmc = ancsBitmapCachedModifiable(c);
	EWAHCompressedBitmap bmd = ancsBitmapCachedModifiable(d);
	EWAHCompressedBitmap cad = bmc.and(bmd);	
	int[] csInts = cad.toArray();
	for (int ix : csInts) {
		cad = cad.andNot(ancsProperBitmapCachedModifiable(classArray[ix]));
	}
	return cad;
}
 
Example 10
Source File: FastOwlSim.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private EWAHCompressedBitmap getNamedLowestCommonSubsumersAsBitmap(int cix, int dix)
		throws UnknownOWLClassException  {
	EWAHCompressedBitmap bmc = ancsBitmapCachedModifiable(cix);
	EWAHCompressedBitmap bmd = ancsBitmapCachedModifiable(dix);
	EWAHCompressedBitmap cad = bmc.and(bmd);	
	int[] csInts = cad.toArray();
	for (int ix : csInts) {
		cad = cad.andNot(ancsProperBitmapCachedModifiable(classArray[ix]));
	}
	return cad;
}
 
Example 11
Source File: FastOwlSim.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private ScoreAttributeSetPair getLowestCommonSubsumerWithICNoCache(int cix, int dix)
		throws UnknownOWLClassException {
	long t = System.currentTimeMillis();
	EWAHCompressedBitmap cad = getNamedLowestCommonSubsumersAsBitmap(cix, dix);

	Set<OWLClass> lcsClasses = new HashSet<OWLClass>();
	double maxScore = 0.0;
	for (int ix : cad.toArray()) {
		// TODO: use getAttributeTriadScore here
		double score = 
				getInformationContentForAttribute(ix);
		double sdiff = score - maxScore;
		if (sdiff >= 0) {
			if (sdiff > 0.01) {
				lcsClasses= new HashSet<OWLClass>(Collections.singleton(classArray[ix]));
				maxScore = score;					
			}
			else {
				lcsClasses.add(classArray[ix]);
				maxScore = score;					
			}
		}
		//			if (score == maxScore) {
		//				lcsClasses.add(classArray[ix]);
		//				maxScore = score;
		//			}
		//			else if (score >= maxScore) {
		//				lcsClasses= new HashSet<OWLClass>(Collections.singleton(classArray[ix]));
		//				maxScore = score;
		//			}
	}
	if (lcsClasses.size() == 0) {
		// TODO - remove obsoletes
		//LOG.warn("Hmmmm "+c+" "+d+" "+lcs);
	}
	totalTimeLCSIC += tdelta(t);
	this.totalCallsLCSIC++;

	return new ScoreAttributeSetPair(maxScore, lcsClasses);
}
 
Example 12
Source File: SimSpeedTest.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public Set<Node<OWLClass>> getNamedCommonSubsumers(OWLClass c, OWLClass d) {
	EWAHCompressedBitmap bmc = ancsBitmapCachedModifiable(c);
	EWAHCompressedBitmap bmd = ancsBitmapCachedModifiable(d);
	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;
}