本文整理汇总了Java中gnu.trove.map.TIntFloatMap.containsKey方法的典型用法代码示例。如果您正苦于以下问题:Java TIntFloatMap.containsKey方法的具体用法?Java TIntFloatMap.containsKey怎么用?Java TIntFloatMap.containsKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gnu.trove.map.TIntFloatMap
的用法示例。
在下文中一共展示了TIntFloatMap.containsKey方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: cosineSimilarity
import gnu.trove.map.TIntFloatMap; //导入方法依赖的package包/类
public static double cosineSimilarity(TIntFloatMap X, TIntFloatMap Y) {
double xDotX = 0.0;
double yDotY = 0.0;
double xDotY = 0.0;
for (int id : X.keys()) {
double x = X.get(id);
xDotX += x * x;
if (Y.containsKey(id)) {
xDotY += x * Y.get(id);
}
}
for (double y : Y.values()) {
yDotY += y * y;
}
return xDotX * yDotY != 0 ? xDotY / Math.sqrt(xDotX * yDotY): 0.0;
}
示例2: compare
import gnu.trove.map.TIntFloatMap; //导入方法依赖的package包/类
public double compare(
TIntFloatMap v1,
TIntFloatMap v2,
boolean sorted)
{
int overlaps = 0;
TIntIterator iter = v1.keySet().iterator();
while (iter.hasNext())
{
int key = iter.next();
if (v2.containsKey(key))
overlaps++;
}
return overlaps / (double)(v1.size() + v2.size() - overlaps);
}
示例3: compare
import gnu.trove.map.TIntFloatMap; //导入方法依赖的package包/类
public double compare(
TIntFloatMap v1,
TIntFloatMap v2,
boolean sorted)
{
//it does not matter if the vectors are sorted or not
double DKL = 0.0;
TIntFloatIterator iter = v1.iterator();
while (iter.hasNext())
{
iter.advance();
int key = iter.key();
if (!v2.containsKey(key))
{
continue;
}
double P = iter.value();
double Q = v2.get(key);
DKL += Math.log(P/Q) * P;
}
return DKL;
}
示例4: makeOutlinkVector
import gnu.trove.map.TIntFloatMap; //导入方法依赖的package包/类
private TIntFloatMap makeOutlinkVector(TIntSet links) {
TIntFloatMap vector = new TIntFloatHashMap();
for (int wpId : links.toArray()) {
vector.put(wpId, (float) Math.log(1.0 * linkCache.getTotalPages() / linkCache
.getInlinks(wpId).size()));
}
if(wlmExtended) {
TIntFloatMap vector2 = new TIntFloatHashMap();
//考虑二级链接
for (int id1 : links.toArray()) {
for (int id2 : linkCache.getOutlinks(id1).toArray()) {
double tfidf = Math.log(1.0 * linkCache.getTotalPages()
/ linkCache.getInlinks(id2).size());
float w = (float) tfidf * vector.get(id1);
float old = 0;
if (vector2.containsKey(id2)) {
old = vector2.get(id2);
}
vector2.put(id2, old + w);
}
}
vector.putAll(vector2);
}
return vector;
}