本文整理汇总了Java中com.hankcs.hanlp.algoritm.ArrayDistance类的典型用法代码示例。如果您正苦于以下问题:Java ArrayDistance类的具体用法?Java ArrayDistance怎么用?Java ArrayDistance使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ArrayDistance类属于com.hankcs.hanlp.algoritm包,在下文中一共展示了ArrayDistance类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: compareTo
import com.hankcs.hanlp.algoritm.ArrayDistance; //导入依赖的package包/类
@Override
public int compareTo(IdVector o)
{
int len1 = idArrayList.size();
int len2 = o.idArrayList.size();
int lim = Math.min(len1, len2);
Iterator<Long[]> iterator1 = idArrayList.iterator();
Iterator<Long[]> iterator2 = o.idArrayList.iterator();
int k = 0;
while (k < lim)
{
Long[] c1 = iterator1.next();
Long[] c2 = iterator2.next();
if (ArrayDistance.computeMinimumDistance(c1, c2) != 0)
{
return ArrayCompare.compare(c1, c2);
}
++k;
}
return len1 - len2;
}
示例2: distance
import com.hankcs.hanlp.algoritm.ArrayDistance; //导入依赖的package包/类
/**
* 语义距离
* @param a
* @param b
* @return
*/
public long distance(String a, String b)
{
Long[] itemA = get(a);
if (itemA == null) return Long.MAX_VALUE / 3;
Long[] itemB = get(b);
if (itemB == null) return Long.MAX_VALUE / 3;
return ArrayDistance.computeAverageDistance(itemA, itemB);
}
示例3: similarity
import com.hankcs.hanlp.algoritm.ArrayDistance; //导入依赖的package包/类
@Override
public Double similarity(IdVector other)
{
Double score = 0.0;
for (Long[] a : idArrayList)
{
for (Long[] b : other.idArrayList)
{
Long distance = ArrayDistance.computeAverageDistance(a, b);
score += 1.0 / (0.1 + distance);
}
}
return score / other.idArrayList.size();
}