Imported Upstream version 0.18.1.1
[platform/upstream/gettext.git] / gettext-tools / src / msgl-fsearch.h
1 /* Fast fuzzy searching among messages.
2    Copyright (C) 2006, 2008 Free Software Foundation, Inc.
3    Written by Bruno Haible <bruno@clisp.org>, 2006.
4
5    This program is free software: you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published by
7    the Free Software Foundation; either version 3 of the License, or
8    (at your option) any later version.
9
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU General Public License for more details.
14
15    You should have received a copy of the GNU General Public License
16    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
17
18 #ifndef _MSGL_FSEARCH_H
19 #define _MSGL_FSEARCH_H 1
20
21 #include "message.h"
22
23 #include <stdbool.h>
24
25
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29
30
31 /* A fuzzy index is a data structure that corresponds to a set of messages,
32    allowing for fuzzy searching of a message.  It is optimized for large sets
33    of messages.  */
34 typedef struct message_fuzzy_index_ty message_fuzzy_index_ty;
35
36 /* Allocate a fuzzy index corresponding to a given list of messages.
37    The list of messages and the msgctxt and msgid fields of the messages
38    inside it must not be modified while the returned fuzzy index is in use.  */
39 extern message_fuzzy_index_ty *
40        message_fuzzy_index_alloc (const message_list_ty *mlp,
41                                   const char *canon_charset);
42
43 /* Find a good match for the given msgctxt and msgid in the given fuzzy index.
44    The match does not need to be optimal.
45    Ignore matches for which the fuzzy_search_goal_function is < LOWER_BOUND.
46    LOWER_BOUND must be >= FUZZY_THRESHOLD.
47    If HEURISTIC is true, only the few best messages among the list - according
48    to a certain heuristic - are considered.  If HEURISTIC is false, all
49    messages with a fuzzy_search_goal_function > FUZZY_THRESHOLD are considered,
50    like in message_list_search_fuzzy (except that in ambiguous cases where
51    several best matches exist, message_list_search_fuzzy chooses the one with
52    the smallest index whereas message_fuzzy_index_search makes a better
53    choice).  */
54 extern message_ty *
55        message_fuzzy_index_search (message_fuzzy_index_ty *findex,
56                                    const char *msgctxt, const char *msgid,
57                                    double lower_bound,
58                                    bool heuristic);
59
60 /* Free a fuzzy index.  */
61 extern void
62        message_fuzzy_index_free (message_fuzzy_index_ty *findex);
63
64
65 #ifdef __cplusplus
66 }
67 #endif
68
69 #endif /* _MSGL_FSEARCH_H */