Java Code Examples for com.googlecode.javaewah.EWAHCompressedBitmap#andCardinality()
The following examples show how to use
com.googlecode.javaewah.EWAHCompressedBitmap#andCardinality() .
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: FastOwlSim.java From owltools with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public AttributePairScores getPairwiseSimilarity(OWLClass c, OWLClass d) throws UnknownOWLClassException { AttributePairScores s = new AttributePairScores(c,d); EWAHCompressedBitmap bmc = ancsBitmapCachedModifiable(c); EWAHCompressedBitmap bmd = ancsBitmapCachedModifiable(d); s.simjScore = bmc.andCardinality(bmd) / (double) bmc.orCardinality(bmd); s.asymmetricSimjScore = bmc.andCardinality(bmd) / (double) bmd.cardinality(); s.inverseAsymmetricSimjScore = bmc.andCardinality(bmd) / (double) bmc.cardinality(); ScoreAttributeSetPair sap = getLowestCommonSubsumerWithIC(c, d); s.lcsIC = sap.score; s.lcsSet = sap.attributeClassSet; return s; }
Example 2
Source File: KeywordJaccard.java From StreamingRec with Apache License 2.0 | 5 votes |
/** * Calculates the Jaccard similarity of two items in terms of their keywords * @param itemKeywords Keywords of the first item * @param anotherItemsKeywords Keywords of the other item * @return the Jaccard similarity */ protected double similarity(EWAHCompressedBitmap itemKeywords, EWAHCompressedBitmap anotherItemsKeywords) { int intersection = itemKeywords.andCardinality(anotherItemsKeywords); if (intersection == 0) { // if the intersection is 0 -> return 0 return 0; } // otherwise calculate the jaccard int union = itemKeywords.orCardinality(anotherItemsKeywords); return intersection * 1d / union * 1d; }
Example 3
Source File: ItemItemCF.java From StreamingRec with Apache License 2.0 | 5 votes |
/** * Calculates the Jaccard similarity of two items in terms of the sets of users * that clicked on them respectively * @param itemClicks Users that clicked on the first item * @param anotherItemsClicks Users that clicked on the other item * @return the Jaccard similarity */ protected double similarity(EWAHCompressedBitmap itemClicks, EWAHCompressedBitmap anotherItemsClicks) { int intersection = itemClicks.andCardinality(anotherItemsClicks); if (intersection == 0) { // if the intersection is 0 -> return 0 return 0; } // otherwise calculate the jaccard int union = itemClicks.orCardinality(anotherItemsClicks); return intersection * 1d / union * 1d; }
Example 4
Source File: FastOwlSim.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public double getAttributeJaccardSimilarity(OWLClass c, OWLClass d) throws UnknownOWLClassException { EWAHCompressedBitmap bmc = ancsBitmapCachedModifiable(c); EWAHCompressedBitmap bmd = ancsBitmapCachedModifiable(d); return bmc.andCardinality(bmd) / (double) bmc.orCardinality(bmd); }
Example 5
Source File: FastOwlSim.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public int getAttributeJaccardSimilarityAsPercent(OWLClass c, OWLClass d) throws UnknownOWLClassException { EWAHCompressedBitmap bmc = ancsBitmapCachedModifiable(c); EWAHCompressedBitmap bmd = ancsBitmapCachedModifiable(d); return (bmc.andCardinality(bmd) * 100) / bmc.orCardinality(bmd); }
Example 6
Source File: FastOwlSim.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public double getElementJaccardSimilarity(OWLNamedIndividual i, OWLNamedIndividual j) throws UnknownOWLClassException { EWAHCompressedBitmap bmc = ancsBitmapCachedModifiable(i); EWAHCompressedBitmap bmd = ancsBitmapCachedModifiable(j); return bmc.andCardinality(bmd) / (double) bmc.orCardinality(bmd); }
Example 7
Source File: FastOwlSim.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public int getElementJaccardSimilarityAsPercent(OWLNamedIndividual i, OWLNamedIndividual j) throws UnknownOWLClassException { EWAHCompressedBitmap bmc = ancsBitmapCachedModifiable(i); EWAHCompressedBitmap bmd = ancsBitmapCachedModifiable(j); return (bmc.andCardinality(bmd) * 100) / bmc.orCardinality(bmd); }
Example 8
Source File: FastOwlSim.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public double getAsymmetricAttributeJaccardSimilarity(OWLClass c, OWLClass d) throws UnknownOWLClassException { EWAHCompressedBitmap bmc = ancsBitmapCachedModifiable(c); EWAHCompressedBitmap bmd = ancsBitmapCachedModifiable(d); return bmc.andCardinality(bmd) / (double) bmd.cardinality(); }
Example 9
Source File: FastOwlSim.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
public double getAsymmetricElementJaccardSimilarity(OWLNamedIndividual i, OWLNamedIndividual j) throws UnknownOWLClassException { EWAHCompressedBitmap bmc = ancsBitmapCachedModifiable(i); EWAHCompressedBitmap bmd = ancsBitmapCachedModifiable(j); return bmc.andCardinality(bmd) / (double) bmd.cardinality(); }
Example 10
Source File: FastOwlSim.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
public int getAsymmetricElementJaccardSimilarityAsPercent(OWLNamedIndividual i, OWLNamedIndividual j) throws UnknownOWLClassException { EWAHCompressedBitmap bmc = ancsBitmapCachedModifiable(i); EWAHCompressedBitmap bmd = ancsBitmapCachedModifiable(j); return (bmc.andCardinality(bmd) * 100) / bmd.cardinality(); }
Example 11
Source File: FastOwlSim.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
private double computeSimJwithBM(EWAHCompressedBitmap iAttsBM, EWAHCompressedBitmap jAttsBM) { int cadSize = iAttsBM.andCardinality(jAttsBM); int cudSize = iAttsBM.orCardinality(jAttsBM); double simJPct = 0; if (cudSize != 0) { simJPct = (cadSize * 100) / cudSize; } return simJPct; }
Example 12
Source File: FastOwlSim.java From owltools with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public int getNumSharedElements(OWLClass c, OWLClass d) throws UnknownOWLClassException { EWAHCompressedBitmap cebm = getElementsForAttributeAsBitmao(c); EWAHCompressedBitmap debm = getElementsForAttributeAsBitmao(d); return cebm.andCardinality(debm); }
Example 13
Source File: FastOwlSim.java From owltools with BSD 3-Clause "New" or "Revised" License | 4 votes |
public int getNumSharedElements(OWLClass c, OWLClass d, OWLClass e) throws UnknownOWLClassException { EWAHCompressedBitmap cebm = getElementsForAttributeAsBitmao(c); EWAHCompressedBitmap debm = getElementsForAttributeAsBitmao(d); EWAHCompressedBitmap eebm = getElementsForAttributeAsBitmao(e); return cebm.andCardinality(debm, eebm); }
Example 14
Source File: FastOwlSim.java From owltools with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public int getNamedCommonSubsumersCount(OWLClass c, OWLClass d) throws UnknownOWLClassException { EWAHCompressedBitmap bmc = ancsBitmapCachedModifiable(c); EWAHCompressedBitmap bmd = ancsBitmapCachedModifiable(d); return bmc.andCardinality(bmd); }
Example 15
Source File: SimSpeedTest.java From owltools with BSD 3-Clause "New" or "Revised" License | 4 votes |
private double jaccardBitmap(OWLClass c, OWLClass d) { EWAHCompressedBitmap bmc = ancsBitmapCachedModifiable(c); EWAHCompressedBitmap bmd = ancsBitmapCachedModifiable(d); return bmc.andCardinality(bmd) / (double) bmc.orCardinality(bmd); }