[Tomoe-cvs 1157] CVS update: tomoe/recognizer

Back to archive index

Hiroyuki Ikezoe ikezo****@users*****
2006年 11月 27日 (月) 16:22:07 JST


Index: tomoe/recognizer/tomoe-recognizer-simple-logic.c
diff -u tomoe/recognizer/tomoe-recognizer-simple-logic.c:1.29 tomoe/recognizer/tomoe-recognizer-simple-logic.c:1.30
--- tomoe/recognizer/tomoe-recognizer-simple-logic.c:1.29	Mon Nov 27 15:22:21 2006
+++ tomoe/recognizer/tomoe-recognizer-simple-logic.c	Mon Nov 27 16:22:07 2006
@@ -17,10 +17,11 @@
  *  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  *  Boston, MA  02111-1307  USA
  *
- *  $Id: tomoe-recognizer-simple-logic.c,v 1.29 2006/11/27 06:22:21 ikezoe Exp $
+ *  $Id: tomoe-recognizer-simple-logic.c,v 1.30 2006/11/27 07:22:07 ikezoe Exp $
  */
 
 #include <stdlib.h>
+#include <string.h>
 #include <math.h>
 #include "tomoe-char.h"
 #include "tomoe-dict.h"
@@ -76,7 +77,7 @@
 {
     /* TomoeRecognizerSimple *recognizer = context; */
     GList *matched = NULL;
-    GArray *matches = NULL;
+    GPtrArray *matches = NULL;
     GPtrArray *cands = NULL;
     GPtrArray *first_cands = NULL;
     guint letters_num = 0;
@@ -127,12 +128,14 @@
         cands = tmp;
     }
 
-    matches = g_array_new (FALSE, FALSE, sizeof (gint));
+    matches = g_ptr_array_new ();
     for (i = 0; i < (guint)cands->len; i++) {
         cand_priv *cand_p;
         GArray *adapted;
         gint pj;
         gint index;
+        TomoeChar *a;
+        gboolean f = TRUE;
 
         cand_p = g_ptr_array_index (cands, i);
         index = cand_p->index;
@@ -148,30 +151,29 @@
                 cand_p->cand,
                 tomoe_candidate_get_score (cand_p->cand) / pj);
 
-        if (!_g_array_has_this_int_value (matches, index)) {
-            const TomoeChar *a = tomoe_candidate_get_character (cand_p->cand);
-            gboolean f = TRUE;
-
-            for (j = 0; j < (guint)matches->len; j++) {
-                const TomoeChar *b = g_ptr_array_index (letters, g_array_index (matches, gint, j));
-                if (!tomoe_char_compare(a, b)) {
-                    f = FALSE;
-                    break;
-                }
-            }
+        a = tomoe_candidate_get_character (cand_p->cand);
 
-            if (f) {
-                TomoeCandidate *c = cand_p->cand;
-                TomoeCandidate *cand;
-                cand = tomoe_candidate_new (tomoe_candidate_get_character (c));
-                tomoe_candidate_set_score (cand, tomoe_candidate_get_score (c));
-                matched = g_list_prepend (matched, cand);
-                g_array_append_val (matches, cand_p->index);
+        for (j = 0; j < (guint)matches->len; j++) {
+            const gchar *c = g_ptr_array_index (matches, j);
+            const gchar *ac = tomoe_char_get_utf8 (a);
+            if (!strcmp(c, ac)) {
+                f = FALSE;
+                break;
             }
         }
+
+        if (f) {
+            TomoeCandidate *c = cand_p->cand;
+            TomoeCandidate *cand;
+            TomoeChar *chr = tomoe_candidate_get_character (c);
+            cand = tomoe_candidate_new (chr);
+            tomoe_candidate_set_score (cand, tomoe_candidate_get_score (c));
+            matched = g_list_prepend (matched, cand);
+            g_ptr_array_add (matches, (gpointer) tomoe_char_get_utf8 (chr));
+        }
     }
 
-    g_array_free (matches, TRUE);
+    g_ptr_array_free (matches, TRUE);
 
     matched = g_list_sort (matched, _candidate_compare_func);
 


tomoe-cvs メーリングリストの案内
Back to archive index