add error report to ngseg
authorPeng Wu <alexepico@gmail.com>
Wed, 20 Jul 2011 06:22:49 +0000 (14:22 +0800)
committerPeng Wu <alexepico@gmail.com>
Wed, 20 Jul 2011 06:22:49 +0000 (14:22 +0800)
utils/segment/ngseg.cpp

index 1e3f6c5..87814bb 100644 (file)
@@ -69,6 +69,15 @@ bool deal_with_segmentable(GArray * current_utf16){
     g_phrase_lookup->convert_to_utf8(results, "\n", result_string);
     if (result_string)
         printf("%s\n", result_string);
+    else {
+        char * result_string = g_utf16_to_utf8
+            ( (utf16_t *) current_utf16->data, current_utf16->len,
+              NULL, NULL, NULL);
+        fprintf(stderr, "Un-segmentable sentence encountered:%s.\n",
+                result_string);
+        g_array_free(results, TRUE);
+        return false;
+    }
     g_array_free(results, TRUE);
     g_free(result_string);
     return true;