summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2012-12-11 14:15:49 +0800
committerPeng Wu <alexepico@gmail.com>2012-12-11 14:15:49 +0800
commit55d9118222721f73cc1d19566427c3f7705303dc (patch)
treec32207906aba92afcd84867285e01645727f06c7
parent20fde3f877ec9448671c2a97ab035b3d844433c0 (diff)
downloadlibpinyin-55d9118222721f73cc1d19566427c3f7705303dc.tar.gz
libpinyin-55d9118222721f73cc1d19566427c3f7705303dc.tar.xz
libpinyin-55d9118222721f73cc1d19566427c3f7705303dc.zip
a safe guard for chewing
-rw-r--r--src/storage/phrase_index.h15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/storage/phrase_index.h b/src/storage/phrase_index.h
index aca74f6..7b3443c 100644
--- a/src/storage/phrase_index.h
+++ b/src/storage/phrase_index.h
@@ -152,16 +152,15 @@ public:
matched += *freq;
}
}
- // use preprocessor to avoid zero freq, in gen_pinyin_table.
- /*
+
+#if 1
+ /* an additional safe guard for chewing. */
if ( 0 == total_freq )
- return 0.1;
- */
+ return 0;
+#endif
+
+ /* used preprocessor to avoid zero freq, in gen_chewing_table. */
gfloat retval = matched / (gfloat) total_freq;
- /*
- if ( 0 == retval )
- return 0.03;
- */
return retval;
}