浏览代码

Add comparision function for shingles.

tags/0.8.0
Vsevolod Stakhov 9 年前
父节点
当前提交
c63bee1078
共有 2 个文件被更改,包括 25 次插入0 次删除
  1. 15
    0
      src/libutil/shingles.c
  2. 10
    0
      src/libutil/shingles.h

+ 15
- 0
src/libutil/shingles.c 查看文件

@@ -135,3 +135,18 @@ rspamd_shingles_default_filter (guint64 *input, gsize count,

return minimal;
}


gdouble rspamd_shingles_compare (const struct rspamd_shingle *a,
const struct rspamd_shingle *b)
{
gint i, common = 0;

for (i = 0; i < RSPAMD_SHINGLE_SIZE; i ++) {
if (a->hashes[i] == b->hashes[i]) {
common ++;
}
}

return (gdouble)common / 84.0;
}

+ 10
- 0
src/libutil/shingles.h 查看文件

@@ -57,6 +57,16 @@ struct rspamd_shingle* rspamd_shingles_generate (GArray *input,
rspamd_shingles_filter filter,
gpointer filterd);

/**
* Compares two shingles and return result as a floating point value - 1.0
* for completely similar shingles and 0.0 for completely different ones
* @param a
* @param b
* @return
*/
gdouble rspamd_shingles_compare (const struct rspamd_shingle *a,
const struct rspamd_shingle *b);

/**
* Default filtering function
*/

正在加载...
取消
保存