static grn_obj * uvector_fin(grn_ctx *ctx, int nargs, grn_obj **args, grn_user_data *user_data) { grn_uvector_tokenizer *tokenizer = user_data->ptr; grn_tokenizer_token_fin(ctx, &(tokenizer->token)); GRN_FREE(tokenizer); return NULL; }
static grn_obj * ngram_fin(grn_ctx *ctx, int nargs, grn_obj **args, grn_user_data *user_data) { grn_ngram_tokenizer *tokenizer = user_data->ptr; grn_tokenizer_token_fin(ctx, &(tokenizer->token)); grn_tokenizer_query_close(ctx, tokenizer->query); GRN_FREE(tokenizer); return NULL; }
static grn_obj * delimited_fin(grn_ctx *ctx, int nargs, grn_obj **args, grn_user_data *user_data) { grn_delimited_tokenizer *tokenizer = user_data->ptr; if (!tokenizer) { return NULL; } grn_tokenizer_query_close(ctx, tokenizer->query); grn_tokenizer_token_fin(ctx, &(tokenizer->token)); GRN_FREE(tokenizer); return NULL; }
/* This function finalizes a tokenization. */ static grn_obj * mecab_fin(grn_ctx *ctx, int nargs, grn_obj **args, grn_user_data *user_data) { grn_mecab_tokenizer *tokenizer = user_data->ptr; grn_tokenizer_token_fin(ctx, &(tokenizer->token)); grn_tokenizer_query_close(ctx, tokenizer->query); if (tokenizer->buf) { GRN_PLUGIN_FREE(ctx, tokenizer->buf); } GRN_PLUGIN_FREE(ctx, tokenizer); return NULL; }
static grn_obj * regexp_fin(grn_ctx *ctx, int nargs, grn_obj **args, grn_user_data *user_data) { grn_regexp_tokenizer *tokenizer = user_data->ptr; if (!tokenizer) { return NULL; } grn_tokenizer_token_fin(ctx, &(tokenizer->token)); grn_tokenizer_query_close(ctx, tokenizer->query); GRN_OBJ_FIN(ctx, &(tokenizer->buffer)); GRN_FREE(tokenizer); return NULL; }
static void stem_fin(grn_ctx *ctx, void *user_data) { grn_stem_token_filter *token_filter = user_data; if (!token_filter) { return; } grn_tokenizer_token_fin(ctx, &(token_filter->token)); if (token_filter->stemmer) { sb_stemmer_delete(token_filter->stemmer); } GRN_PLUGIN_FREE(ctx, token_filter); }
static grn_obj * sample_fin(grn_ctx *ctx, GNUC_UNUSED int nargs, GNUC_UNUSED grn_obj **args, grn_user_data *user_data) { sample_tokenizer *tokenizer = user_data->ptr; if (!tokenizer) { return NULL; } grn_tokenizer_token_fin(ctx, &(tokenizer->token)); grn_tokenizer_query_close(ctx, tokenizer->query); GRN_PLUGIN_FREE(ctx, tokenizer); return NULL; }
static grn_obj * yangram_fin(grn_ctx *ctx, GNUC_UNUSED int nargs, GNUC_UNUSED grn_obj **args, grn_user_data *user_data) { grn_yangram_tokenizer *tokenizer = user_data->ptr; if (!tokenizer) { return NULL; } if (tokenizer->vgram_table) { grn_obj_unlink(ctx, tokenizer->vgram_table); } if (tokenizer->phrase_table) { grn_obj_unlink(ctx, tokenizer->phrase_table); GRN_PLUGIN_FREE(ctx, tokenizer->hits); } grn_tokenizer_query_close(ctx, tokenizer->query); grn_tokenizer_token_fin(ctx, &(tokenizer->token)); GRN_PLUGIN_FREE(ctx, tokenizer); return NULL; }