本文整理匯總了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();
}