2017-07-07 20:47:27 +08:00
|
|
|
#ifndef _GRAM_INDEX_ENGINE_
|
|
|
|
|
#define _GRAM_INDEX_ENGINE_
|
2015-11-09 16:07:50 +08:00
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
2018-12-04 20:12:56 +08:00
|
|
|
enum GIE_operation
|
|
|
|
|
{
|
|
|
|
|
GIE_INSERT_OPT,
|
|
|
|
|
GIE_DELETE_OPT
|
|
|
|
|
};
|
|
|
|
|
enum GIE_INPUT_FORMAT
|
|
|
|
|
{
|
|
|
|
|
GIE_INPUT_FORMAT_PLAIN,
|
|
|
|
|
GIE_INPUT_FORMAT_SFH
|
|
|
|
|
};
|
2015-11-09 16:07:50 +08:00
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
/* data */
|
|
|
|
|
}GIE_handle_t;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
unsigned int id;
|
2017-07-07 20:47:27 +08:00
|
|
|
unsigned int sfh_length;//size of fuzzy_hash
|
2018-12-04 20:12:56 +08:00
|
|
|
enum GIE_operation operation;//GIE_INSERT_OPT or GIE_DELETE_OPT.if operation is GIE_DELETE_OPT, only id is needed;
|
2015-11-10 18:29:42 +08:00
|
|
|
short cfds_lvl;
|
2017-07-07 20:47:27 +08:00
|
|
|
char * sfh;
|
2015-11-09 16:07:50 +08:00
|
|
|
void * tag;
|
2015-11-10 18:29:42 +08:00
|
|
|
}GIE_digest_t;
|
2015-11-09 16:07:50 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
unsigned int id;
|
2015-11-10 18:29:42 +08:00
|
|
|
short cfds_lvl;
|
2015-11-09 16:07:50 +08:00
|
|
|
void * tag;
|
2015-11-10 18:29:42 +08:00
|
|
|
}GIE_result_t;
|
2015-11-09 16:07:50 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
2017-07-07 20:47:27 +08:00
|
|
|
unsigned int gram_value;
|
|
|
|
|
//unsigned int htable_num;
|
|
|
|
|
unsigned int position_accuracy;
|
2018-12-04 20:12:56 +08:00
|
|
|
enum GIE_INPUT_FORMAT format; //if format==GIE_INPUT_FORMAT_SFH, means the input string is a GIE_INPUT_FORMAT_SFH string
|
2017-07-07 20:47:27 +08:00
|
|
|
//else id format==PALIN, means the input string is common string
|
2018-12-04 20:12:56 +08:00
|
|
|
int ED_reexamine;//if ED_reexamine==1, calculate edit distance to verify the final result
|
2015-11-09 16:07:50 +08:00
|
|
|
}GIE_create_para_t;
|
|
|
|
|
|
|
|
|
|
|
2015-11-10 18:29:42 +08:00
|
|
|
GIE_handle_t * GIE_create(const GIE_create_para_t * para);
|
2015-11-09 16:07:50 +08:00
|
|
|
|
|
|
|
|
|
2015-11-10 18:29:42 +08:00
|
|
|
int GIE_update(GIE_handle_t * handle, GIE_digest_t ** digests, int size);
|
2015-11-09 16:07:50 +08:00
|
|
|
|
2017-07-07 20:47:27 +08:00
|
|
|
|
2015-11-10 18:29:42 +08:00
|
|
|
//return actual matched result count
|
|
|
|
|
//return 0 when matched nothing;
|
|
|
|
|
//return -1 when error occurs;
|
2017-07-07 20:47:27 +08:00
|
|
|
int GIE_query(GIE_handle_t * handle, const char * data, int data_len, GIE_result_t * results, int result_size);
|
2015-11-09 16:07:50 +08:00
|
|
|
|
|
|
|
|
void GIE_destory(GIE_handle_t * handle);
|
2017-08-11 11:09:06 +08:00
|
|
|
int GIE_string_similiarity(const char *str1, int len1, const char *str2, int len2);
|
|
|
|
|
int GIE_sfh_similiarity(const char *sfh1, int len1, const char *sfh2, int len2);
|
2015-11-09 16:07:50 +08:00
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|