私はelki 0.7を使ってツイート(テキスト、日付、著者など)をクラスタリングしています。elkiの文字列のカストム距離関数を定義する方法は?
最初のステップでは、つぶやきのテキストをクラスタ化したいと思います。
私は単純な距離関数を書いており、将来私はそれをカスタマイズしたいと思います。
public class Distance extends AbstractPrimitiveDistanceFunction<String> {
@Override
public double distance(String str1, String str2) {
int row1 = rowNumber.get(str1),
row2 = rowNumber.get(str2);
return 1 - similarity[row1][row2];
}
@Override
public SimpleTypeInformation<? super String> getInputTypeRestriction() {
return VectorFieldTypeInformation.typeRequest(String.class, 2, 2);
}
}
類似度は、ツイートの正規化類似度(tf-idfを使用)を計算した配列です。 クラスタリングを実行したいが、SimpleTypeInformation関数にエラーがある。
The type of <V>typeRequest(Class<? super V>,int,int) is erroneous
where V is a type-variable:
V extends FeatureVector<?> declared in method <V>typeRequest(Class<? super V>,int,int)
incompatible types: inferred type does not conform to upper bound(s)
inferred: String
upper bound(s): String,FeatureVector<?>
アイデアはありますか?
ベクトルフィールド*はありませんが、単一の文字列ですか? –
https://github.com/elki-project/elki/blob/master/elki-core-distance/src/main/java/de/lmu/ifi/dbs/elki/distance/distancefunction/strings/LevenshteinDistanceFunctionを参照してください。文字列距離関数のjava。 –