the fuzzy search in the compendiums.
+2008-09-14 Bruno Haible <bruno@clisp.org>
+
+ * msgl-fsearch.h (message_fuzzy_index_search): Add 'lower_bound'
+ argument.
+ * msgl-fsearch.c (message_fuzzy_index_search): Likewise.
+ * msgmerge.c (definitions_search_fuzzy): Use the result of the fuzzy
+ search in the current list as a lower bound for the fuzzy search in the
+ compendiums.
+
2008-09-14 Bruno Haible <bruno@clisp.org>
* message.h (message_list_search_fuzzy, FUZZY_THRESHOLD): Clarify
}
/* Find a good match for the given msgctxt and msgid in the given fuzzy index.
- The match does not need to be optimal. */
+ The match does not need to be optimal.
+ Ignore matches for which the fuzzy_search_goal_function is < LOWER_BOUND.
+ LOWER_BOUND must be >= FUZZY_THRESHOLD. */
message_ty *
message_fuzzy_index_search (message_fuzzy_index_ty *findex,
- const char *msgctxt, const char *msgid)
+ const char *msgctxt, const char *msgid,
+ double lower_bound)
{
const char *str = msgid;
if (count > accu.nitems)
count = accu.nitems;
- best_weight = FUZZY_THRESHOLD;
+ best_weight = lower_bound;
best_mp = NULL;
for (ptr = accu.item; count > 0; ptr++, count--)
{
if (!(lmax <= SHORT_MSG_MAX))
abort ();
- best_weight = FUZZY_THRESHOLD;
+ best_weight = lower_bound;
best_mp = NULL;
for (l = lmin; l <= lmax; l++)
{
/* Fast fuzzy searching among messages.
- Copyright (C) 2006 Free Software Foundation, Inc.
+ Copyright (C) 2006, 2008 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2006.
This program is free software: you can redistribute it and/or modify
const char *canon_charset);
/* Find a good match for the given msgctxt and msgid in the given fuzzy index.
- The match does not need to be optimal. */
+ The match does not need to be optimal.
+ Ignore matches for which the fuzzy_search_goal_function is < LOWER_BOUND.
+ LOWER_BOUND must be >= FUZZY_THRESHOLD. */
extern message_ty *
message_fuzzy_index_search (message_fuzzy_index_ty *findex,
- const char *msgctxt, const char *msgid);
+ const char *msgctxt, const char *msgid,
+ double lower_bound);
/* Free a fuzzy index. */
extern void
msgctxt, msgid);
if (compendiums != NULL)
{
+ double lower_bound_for_mp2;
message_ty *mp2;
+ lower_bound_for_mp2 =
+ (mp1 != NULL
+ ? fuzzy_search_goal_function (mp1, msgctxt, msgid, 0.0)
+ : FUZZY_THRESHOLD);
+ /* This lower bound must be >= FUZZY_THRESHOLD. */
+ if (!(lower_bound_for_mp2 >= FUZZY_THRESHOLD))
+ abort ();
+
/* Create the fuzzy index lazily. */
if (definitions->comp_findex == NULL)
definitions_init_comp_findex (definitions);
mp2 = message_fuzzy_index_search (definitions->comp_findex,
- msgctxt, msgid);
+ msgctxt, msgid,
+ lower_bound_for_mp2);
/* Choose the best among mp1, mp2. */
if (mp1 == NULL
|| (mp2 != NULL
- && (fuzzy_search_goal_function (mp2, msgctxt, msgid, 0.0)
- > fuzzy_search_goal_function (mp1, msgctxt, msgid, 0.0))))
+ && (fuzzy_search_goal_function (mp2, msgctxt, msgid,
+ lower_bound_for_mp2)
+ > lower_bound_for_mp2)))
mp1 = mp2;
}