diff options
| author | Peng Wu <alexepico@gmail.com> | 2010-09-10 17:28:07 +0800 |
|---|---|---|
| committer | Peng Wu <alexepico@gmail.com> | 2010-09-10 17:28:07 +0800 |
| commit | 3db9ee7e2255b01e53865677dabf3fb680bc2b2e (patch) | |
| tree | 2b7ef2c1a7db3c44d9eb94c6002ceff3a344afee | |
| parent | 598490883a327c0ab0c414e5851d8e749403492e (diff) | |
| download | libpinyin-3db9ee7e2255b01e53865677dabf3fb680bc2b2e.tar.gz libpinyin-3db9ee7e2255b01e53865677dabf3fb680bc2b2e.tar.xz libpinyin-3db9ee7e2255b01e53865677dabf3fb680bc2b2e.zip | |
make spseg run
| -rw-r--r-- | src/segment/spseg.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/segment/spseg.cpp b/src/segment/spseg.cpp index 238c732..f4522f2 100644 --- a/src/segment/spseg.cpp +++ b/src/segment/spseg.cpp @@ -41,7 +41,7 @@ struct SegmentStep{ utf16_t * m_phrase; size_t m_phrase_len; //use formula W = number of words. Zero handle means one word. - size_t m_nword; + guint m_nword; //backtrace information, -1 one step backward. gint m_backward_nstep; public: @@ -68,6 +68,9 @@ bool segment(PhraseLargeTable * phrases, //Lookup Phrase g_array_append_val(steps, step); } + SegmentStep * first_step = &g_array_index(steps, SegmentStep, 0); + first_step->m_nword = 0; + for ( glong i = 0; i < phrase_len + 1; ++i ) { SegmentStep * step_begin = &g_array_index(steps, SegmentStep, i); size_t nword = step_begin->m_nword; @@ -104,9 +107,10 @@ bool backtrace(GArray * steps, glong phrase_len, GArray * strings){ g_array_set_size(strings, 0); while ( cur_step ){ SegmentStep * step = &g_array_index(steps, SegmentStep, cur_step); - step->m_nword = 0; step->m_backward_nstep = 0; g_array_append_val(strings, *step); cur_step = cur_step + step->m_backward_nstep; + //intended to avoid leaking internal informations + step->m_nword = 0; step->m_backward_nstep = 0; } //reverse the strings |
