Java で次の基本的なスライディング ウィンドウ アルゴリズムを実装しようとしています。私はそれの基本的な考え方を理解していますが、いくつかの言葉遣い、特に太字の文に少し混乱しています:
固定幅 w のスライディング ウィンドウがファイル全体を移動し、ファイル内のすべての位置 k で、その内容のフィンガープリントが計算されます。k をチャンク境界とする (つまり、Fk mod n = 0)。チャンク全体のハッシュを取得する代わりに、このチャンク内のスライディング ウィンドウの数値的に最小のフィンガープリントを選択します。次に、チャンク内でこのランダムに選択されたウィンドウのハッシュを計算します。直観的には、このアプローチにより、チャンク内の小さな編集が類似度の計算に与える影響が少なくなります。この方法では、署名内の指紋の数が文書の長さに比例する可変長の文書署名が作成されます。
以下のコード/結果をご覧ください。アルゴリズムの基本的な考え方を理解していますか? 太字のテキストに従って、「チャンク内のスライディング ウィンドウの数値的に最小のフィンガープリントを選択する」とはどういう意味ですか? 現在、チャンク全体をハッシュしています。
コード:
public class BSW {
/**
* @param args
*/
public static void main(String[] args) {
int w = 15; // fixed width of sliding window
char[] chars = "Once upon a time there lived in a certain village a little
country girl, the prettiest creature who was ever seen. Her mother was
excessively fond of her; and her grandmother doted on her still more. This
good woman had a little red riding hood made for her. It suited the girl so
extremely well that everybody called her Little Red Riding Hood."
.toCharArray();
List<String> fingerprints = new ArrayList<String>();
for (int i = 0; i < chars.length; i = i + w) {
StringBuffer sb = new StringBuffer();
if (i + w < chars.length) {
sb.append(chars, i, w);
System.out.println(i + ". " + sb.toString());
} else {
sb.append(chars, i, chars.length - i);
System.out.println(i + ". " + sb.toString());
}
fingerprints.add(hash(sb));
}
}
private static String hash(StringBuffer sb) {
// Implement hash (MD5)
return sb.toString();
}
}
結果:
0. Once upon a tim
15. e there lived i
30. n a certain vil
45. lage a little c
60. ountry girl, th
75. e prettiest cre
90. ature who was e
105. ver seen. Her m
120. other was exces
135. sively fond of
150. her; and her gr
165. andmother doted
180. on her still m
195. ore. This good
210. woman had a lit
225. tle red riding
240. hood made for h
255. er. It suited t
270. he girl so extr
285. emely well that
300. everybody call
315. ed her Little R
330. ed Riding Hood.