gtranslator r3751 - in trunk/src: . translation-memory translation-memory/berkeley
- From: icq svn gnome org
- To: svn-commits-list gnome org
- Subject: gtranslator r3751 - in trunk/src: . translation-memory translation-memory/berkeley
- Date: Mon, 22 Sep 2008 09:46:43 +0000 (UTC)
Author: icq
Date: Mon Sep 22 09:46:43 2008
New Revision: 3751
URL: http://svn.gnome.org/viewvc/gtranslator?rev=3751&view=rev
Log:
2008-09-02 Ignacio Casal Quinteiro <nacho resa gmail com>
* application.c (gtranslator_application_init):
* translation-memory/berkeley/berkeley.c
(gtranslator_berkeley_lookup),
(gtranslator_berkeley_set_max_items),
(gtranslator_translation_memory_iface_init),
(gtranslator_berkeley_init):
* translation-memory/translation-memory.c
(gtranslator_translation_memory_set_max_items),
(gtranslator_translation_memory_set_max_items_default),
(gtranslator_translation_memory_base_init):
* translation-memory/translation-memory.h:
Added set_max_default funcs to get less items when searching in
database.
Modified:
trunk/src/ChangeLog
trunk/src/application.c
trunk/src/translation-memory/berkeley/berkeley.c
trunk/src/translation-memory/translation-memory.c
trunk/src/translation-memory/translation-memory.h
Modified: trunk/src/application.c
==============================================================================
--- trunk/src/application.c (original)
+++ trunk/src/application.c Mon Sep 22 09:46:43 2008
@@ -223,6 +223,8 @@
gtranslator_prefs_manager_get_missing_words ());
gtranslator_translation_memory_set_max_delta (application->priv->tm,
gtranslator_prefs_manager_get_sentence_length ());
+ gtranslator_translation_memory_set_max_items (application->priv->tm,
+ 10);
}
Modified: trunk/src/translation-memory/berkeley/berkeley.c
==============================================================================
--- trunk/src/translation-memory/berkeley/berkeley.c (original)
+++ trunk/src/translation-memory/berkeley/berkeley.c Mon Sep 22 09:46:43 2008
@@ -57,6 +57,7 @@
gsize max_omits;
gsize max_delta;
+ gint max_items;
};
static gboolean
@@ -503,7 +504,7 @@
if (array != NULL)
{
- while (i < array->len -1)
+ while (i < array->len -1 && i < ber->priv->max_items)
{
g_hash_table_insert (hash, g_ptr_array_index (array, i),
GINT_TO_POINTER (100));
@@ -520,9 +521,9 @@
// MAX_DELTA is max difference in sentences lengths).
// Start with best matches first, continue to worse ones.
words = gtranslator_utils_split_string_in_words (phrase);
- for (omits = 0; omits <= ber->priv->max_omits; omits++)
+ for (omits = 0; omits <= ber->priv->max_omits && g_hash_table_size (hash) < ber->priv->max_items; omits++)
{
- for (delta = 0; delta <= ber->priv->max_delta; delta++)
+ for (delta = 0; delta <= ber->priv->max_delta && g_hash_table_size (hash) < ber->priv->max_items; delta++)
{
look_fuzzy (ber, words, &hash, omits, delta);
}
@@ -563,12 +564,22 @@
}
static void
+gtranslator_berkeley_set_max_items (GtranslatorTranslationMemory *tm,
+ gint items)
+{
+ GtranslatorBerkeley *ber = GTR_BERKELEY (tm);
+
+ ber->priv->max_items = items;
+}
+
+static void
gtranslator_translation_memory_iface_init (GtranslatorTranslationMemoryIface *iface)
{
iface->store = gtranslator_berkeley_store;
iface->lookup = gtranslator_berkeley_lookup;
iface->set_max_omits = gtranslator_berkeley_set_max_omits;
iface->set_max_delta = gtranslator_berkeley_set_max_delta;
+ iface->set_max_items = gtranslator_berkeley_set_max_items;
}
static void
@@ -581,6 +592,7 @@
pf->priv->words = gtranslator_db_words_new ();
pf->priv->max_omits = 0;
pf->priv->max_delta = 0;
+ pf->priv->max_items = 0;
}
static void
Modified: trunk/src/translation-memory/translation-memory.c
==============================================================================
--- trunk/src/translation-memory/translation-memory.c (original)
+++ trunk/src/translation-memory/translation-memory.c Mon Sep 22 09:46:43 2008
@@ -112,6 +112,28 @@
g_return_if_reached ();
}
+/**
+ * gtranslator_translation_memory_set_max_items:
+ * @items: the max item to return in lookup
+ *
+ * Sets the number of item to return in gtranslator_translation_memory_lookup().
+ */
+void
+gtranslator_translation_memory_set_max_items (GtranslatorTranslationMemory *obj,
+ gint items)
+{
+ g_return_if_fail (GTR_IS_TRANSLATION_MEMORY (obj));
+ GTR_TRANSLATION_MEMORY_GET_IFACE (obj)->set_max_items (obj, items);
+}
+
+/* Default implementation */
+static void
+gtranslator_translation_memory_set_max_items_default (GtranslatorTranslationMemory *obj,
+ gint items)
+{
+ g_return_if_reached ();
+}
+
static void
gtranslator_translation_memory_base_init (GtranslatorTranslationMemoryIface* klass)
{
@@ -121,6 +143,7 @@
klass->lookup = gtranslator_translation_memory_lookup_default;
klass->set_max_omits = gtranslator_translation_memory_set_max_omits_default;
klass->set_max_delta = gtranslator_translation_memory_set_max_delta_default;
+ klass->set_max_items = gtranslator_translation_memory_set_max_items_default;
if (!initialized) {
Modified: trunk/src/translation-memory/translation-memory.h
==============================================================================
--- trunk/src/translation-memory/translation-memory.h (original)
+++ trunk/src/translation-memory/translation-memory.h Mon Sep 22 09:46:43 2008
@@ -43,6 +43,8 @@
gsize omits);
void (*set_max_delta) (GtranslatorTranslationMemory *obj,
gsize delta);
+ void (*set_max_items) (GtranslatorTranslationMemory *obj,
+ gint items);
};
typedef struct _GtranslatorTranslationMemoryMatch GtranslatorTranslationMemoryMatch;
@@ -66,6 +68,9 @@
void gtranslator_translation_memory_set_max_delta (GtranslatorTranslationMemory *obj,
gsize delta);
+void gtranslator_translation_memory_set_max_items (GtranslatorTranslationMemory *obj,
+ gint items);
+
G_END_DECLS
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]