summaryrefslogtreecommitdiffstats
path: root/src/libstat/tokenizers/tokenizers.h
blob: 0bc5948423b30f00fe981564443148cab109ac6d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#ifndef TOKENIZERS_H
#define TOKENIZERS_H

#include "config.h"
#include "mem_pool.h"
#include "fstring.h"
#include "main.h"
#include "stat_api.h"

#define RSPAMD_DEFAULT_TOKENIZER "osb"

/* Common tokenizer structure */
struct rspamd_stat_tokenizer {
	gchar *name;
	gint (*tokenize_func)(struct rspamd_tokenizer_config *cf,
			rspamd_mempool_t *pool,
			GArray *words,
			GTree *result,
			gboolean is_utf);
};

/* Compare two token nodes */
int token_node_compare_func (gconstpointer a, gconstpointer b);

/* Get next word from specified f_str_t buf */
gchar * rspamd_tokenizer_get_word (rspamd_fstring_t *buf,
		rspamd_fstring_t *token, GList **exceptions);

/* Tokenize text into array of words (rspamd_fstring_t type) */
GArray * rspamd_tokenize_text (gchar *text, gsize len, gboolean is_utf,
		gsize min_len, GList **exceptions);

/* OSB tokenize function */
int osb_tokenize_text (struct rspamd_tokenizer_config *cf,
	rspamd_mempool_t *pool,
	GArray *input,
	GTree *tokens,
	gboolean is_utf);

#endif
/*
 * vi:ts=4
 */