Update to 0.8.1

This commit is contained in:
Peng Wu 2013-02-28 12:41:21 +08:00
parent d32742eef0
commit 0f4ee459b0
4 changed files with 392 additions and 85 deletions

1
.gitignore vendored
View File

@ -15,3 +15,4 @@
/libpinyin-0.7.91.tar.gz
/libpinyin-0.7.92.tar.gz
/libpinyin-0.8.0.tar.gz
/libpinyin-0.8.1.tar.gz

View File

@ -1,93 +1,395 @@
From f21bba5df05c174ff91bb89d86b0d383767f99dd Mon Sep 17 00:00:00 2001
From 0bd4ccf6a1a74e12a1921578d8338c9c281fdf87 Mon Sep 17 00:00:00 2001
From: Peng Wu <alexepico@gmail.com>
Date: Tue, 11 Dec 2012 14:15:49 +0800
Subject: [PATCH 1/2] a safe guard for chewing
Date: Sun, 17 Feb 2013 17:28:43 +0800
Subject: [PATCH 1/2] Fixes issue reported by fundawang:
https://github.com/libpinyin/libpinyin/issues/33
merge libpinyin-0.8.0-link.patch.
---
configure.ac | 8 --------
src/Makefile.am | 4 ++--
src/lookup/Makefile.am | 2 +-
src/storage/Makefile.am | 2 +-
tests/Makefile.am | 8 ++++----
tests/include/Makefile.am | 2 +-
tests/lookup/Makefile.am | 6 +++---
tests/storage/Makefile.am | 16 ++++++++--------
utils/segment/Makefile.am | 6 +++---
utils/storage/Makefile.am | 10 +++++-----
utils/training/Makefile.am | 28 ++++++++++++++--------------
11 files changed, 42 insertions(+), 50 deletions(-)
diff --git a/configure.ac b/configure.ac
index a71b546..0258f46 100644
--- a/configure.ac
+++ b/configure.ac
@@ -54,14 +54,6 @@ AC_SUBST(LIBTOOL_EXPORT_OPTIONS)
# Checks for libraries.
PKG_CHECK_MODULES(GLIB2, [glib-2.0 >= 2.4.0])
-GLIB2_CPPFLAGS=`$PKG_CONFIG --cflags glib-2.0`
-
-AC_SUBST(GLIB2_CPPFLAGS)
-
-GLIB2_LDFLAGS=`$PKG_CONFIG --libs glib-2.0`
-
-AC_SUBST(GLIB2_LDFLAGS)
-
# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([locale.h stdlib.h string.h sys/time.h unistd.h])
diff --git a/src/Makefile.am b/src/Makefile.am
index 5ac2c6f..5600c86 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -30,7 +30,7 @@ INCLUDES = -I$(top_srcdir)/src \
-I$(top_srcdir)/src/include \
-I$(top_srcdir)/src/storage \
-I$(top_srcdir)/src/lookup \
- @GLIB2_CPPFLAGS@
+ @GLIB2_CFLAGS@
libpinyinincludedir = $(includedir)/libpinyin-@VERSION@
@@ -44,7 +44,7 @@ noinst_LTLIBRARIES = libpinyin_internal.la
libpinyin_la_SOURCES = pinyin.cpp
-libpinyin_la_LIBADD = storage/libstorage.la lookup/liblookup.la
+libpinyin_la_LIBADD = storage/libstorage.la lookup/liblookup.la @GLIB2_LIBS@
libpinyin_la_LDFLAGS = -Wl,--version-script=$(srcdir)/libpinyin.ver \
-version-info @LT_VERSION_INFO@
diff --git a/src/lookup/Makefile.am b/src/lookup/Makefile.am
index 3f15a99..00d7df4 100644
--- a/src/lookup/Makefile.am
+++ b/src/lookup/Makefile.am
@@ -19,7 +19,7 @@ MAINTAINERCLEANFILES = Makefile.in
INCLUDES = -I$(top_srcdir)/src/include \
-I$(top_srcdir)/src/storage \
- @GLIB2_CPPFLAGS@
+ @GLIB2_CFLAGS@
noinst_HEADERS = lookup.h \
pinyin_lookup2.h \
diff --git a/src/storage/Makefile.am b/src/storage/Makefile.am
index 322a9b5..4a2f1f8 100644
--- a/src/storage/Makefile.am
+++ b/src/storage/Makefile.am
@@ -17,7 +17,7 @@
INCLUDES = -I$(top_srcdir)/src/include \
-I$(top_srcdir)/src/storage \
- @GLIB2_CPPFLAGS@
+ @GLIB2_CFLAGS@
libpinyinincludedir = $(includedir)/libpinyin-@VERSION@
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 84b4518..8208214 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -28,7 +28,7 @@ INCLUDES = -I$(top_srcdir)/src \
-I$(top_srcdir)/src/include \
-I$(top_srcdir)/src/storage \
-I$(top_srcdir)/src/lookup \
- @GLIB2_CPPFLAGS@
+ @GLIB2_CFLAGS@
noinst_HEADERS = timer.h \
tests_helper.h
@@ -39,12 +39,12 @@ noinst_PROGRAMS = test_pinyin \
test_pinyin_SOURCES = test_pinyin.cpp
-test_pinyin_LDADD = ../src/libpinyin.la @GLIB2_LDFLAGS@
+test_pinyin_LDADD = ../src/libpinyin.la @GLIB2_LIBS@
test_phrase_SOURCES = test_phrase.cpp
-test_phrase_LDADD = ../src/libpinyin.la @GLIB2_LDFLAGS@
+test_phrase_LDADD = ../src/libpinyin.la @GLIB2_LIBS@
test_chewing_SOURCES = test_chewing.cpp
-test_chewing_LDADD = ../src/libpinyin.la @GLIB2_LDFLAGS@
+test_chewing_LDADD = ../src/libpinyin.la @GLIB2_LIBS@
diff --git a/tests/include/Makefile.am b/tests/include/Makefile.am
index 656c665..7174bec 100644
--- a/tests/include/Makefile.am
+++ b/tests/include/Makefile.am
@@ -19,7 +19,7 @@ INCLUDES = -I$(top_srcdir)/src \
-I$(top_srcdir)/src/include \
-I$(top_srcdir)/src/storage \
-I$(top_srcdir)/src/lookup \
- @GLIB2_CPPFLAGS@
+ @GLIB2_CFLAGS@
TESTS = test_memory_chunk
diff --git a/tests/lookup/Makefile.am b/tests/lookup/Makefile.am
index f0eb408..4bcc176 100644
--- a/tests/lookup/Makefile.am
+++ b/tests/lookup/Makefile.am
@@ -20,15 +20,15 @@ INCLUDES = -I$(top_srcdir)/src \
-I$(top_srcdir)/src/storage \
-I$(top_srcdir)/src/lookup \
-I$(top_srcdir)/tests \
- @GLIB2_CPPFLAGS@
+ @GLIB2_CFLAGS@
noinst_PROGRAMS = test_pinyin_lookup \
test_phrase_lookup
test_pinyin_lookup_SOURCES = test_pinyin_lookup.cpp
-test_pinyin_lookup_LDADD = ../../src/libpinyin_internal.la @GLIB2_LDFLAGS@
+test_pinyin_lookup_LDADD = ../../src/libpinyin_internal.la @GLIB2_LIBS@
test_phrase_lookup_SOURCES = test_phrase_lookup.cpp
-test_phrase_lookup_LDADD = ../../src/libpinyin_internal.la @GLIB2_LDFLAGS@
\ No newline at end of file
+test_phrase_lookup_LDADD = ../../src/libpinyin_internal.la @GLIB2_LIBS@
\ No newline at end of file
diff --git a/tests/storage/Makefile.am b/tests/storage/Makefile.am
index df20f67..7b03120 100644
--- a/tests/storage/Makefile.am
+++ b/tests/storage/Makefile.am
@@ -20,7 +20,7 @@ INCLUDES = -I$(top_srcdir)/src \
-I$(top_srcdir)/src/storage \
-I$(top_srcdir)/src/lookup \
-I$(top_srcdir)/tests \
- @GLIB2_CPPFLAGS@
+ @GLIB2_CFLAGS@
TESTS = test_phrase_index_logger \
test_ngram \
@@ -37,30 +37,30 @@ noinst_PROGRAMS = test_phrase_index \
test_phrase_index_SOURCES = test_phrase_index.cpp
-test_phrase_index_LDADD = ../../src/libpinyin_internal.la @GLIB2_LDFLAGS@
+test_phrase_index_LDADD = ../../src/libpinyin_internal.la @GLIB2_LIBS@
test_phrase_index_logger_SOURCES = test_phrase_index_logger.cpp
test_phrase_index_logger_LDADD = ../../src/libpinyin_internal.la \
- @GLIB2_LDFLAGS@
+ @GLIB2_LIBS@
test_phrase_table_SOURCES = test_phrase_table.cpp
-test_phrase_table_LDADD = ../../src/libpinyin_internal.la @GLIB2_LDFLAGS@
+test_phrase_table_LDADD = ../../src/libpinyin_internal.la @GLIB2_LIBS@
test_ngram_SOURCES = test_ngram.cpp
-test_ngram_LDADD = ../../src/libpinyin_internal.la @GLIB2_LDFLAGS@
+test_ngram_LDADD = ../../src/libpinyin_internal.la @GLIB2_LIBS@
test_flexible_ngram_SOURCES = test_flexible_ngram.cpp
test_flexible_ngram_LDADD = ../../src/libpinyin_internal.la \
- @GLIB2_LDFLAGS@
+ @GLIB2_LIBS@
test_parser2_SOURCES = test_parser2.cpp
-test_parser2_LDADD = ../../src/libpinyin_internal.la @GLIB2_LDFLAGS@
+test_parser2_LDADD = ../../src/libpinyin_internal.la @GLIB2_LIBS@
test_chewing_table_SOURCES = test_chewing_table.cpp
-test_chewing_table_LDADD = ../../src/libpinyin_internal.la @GLIB2_LDFLAGS@
+test_chewing_table_LDADD = ../../src/libpinyin_internal.la @GLIB2_LIBS@
diff --git a/utils/segment/Makefile.am b/utils/segment/Makefile.am
index 184b7af..5315266 100644
--- a/utils/segment/Makefile.am
+++ b/utils/segment/Makefile.am
@@ -22,14 +22,14 @@ INCLUDES = -I$(top_srcdir)/src \
-I$(top_srcdir)/src/storage \
-I$(top_srcdir)/src/lookup \
-I$(top_srcdir)/utils \
- @GLIB2_CPPFLAGS@
+ @GLIB2_CFLAGS@
noinst_PROGRAMS = spseg ngseg
spseg_SOURCES = spseg.cpp
-spseg_LDADD = ../../src/libpinyin_internal.la @GLIB2_LDFLAGS@
+spseg_LDADD = ../../src/libpinyin_internal.la @GLIB2_LIBS@
ngseg_SOURCES = ngseg.cpp
-ngseg_LDADD = ../../src/libpinyin_internal.la @GLIB2_LDFLAGS@
+ngseg_LDADD = ../../src/libpinyin_internal.la @GLIB2_LIBS@
diff --git a/utils/storage/Makefile.am b/utils/storage/Makefile.am
index 944d647..321f426 100644
--- a/utils/storage/Makefile.am
+++ b/utils/storage/Makefile.am
@@ -20,7 +20,7 @@ INCLUDES = -I$(top_srcdir)/src \
-I$(top_srcdir)/src/storage \
-I$(top_srcdir)/src/lookup \
-I$(top_srcdir)/utils \
- @GLIB2_CPPFLAGS@
+ @GLIB2_CFLAGS@
bin_PROGRAMS = gen_binary_files \
import_interpolation
@@ -30,16 +30,16 @@ noinst_PROGRAMS = export_interpolation \
gen_binary_files_SOURCES = gen_binary_files.cpp
-gen_binary_files_LDADD = ../../src/libpinyin_internal.la @GLIB2_LDFLAGS@
+gen_binary_files_LDADD = ../../src/libpinyin_internal.la @GLIB2_LIBS@
import_interpolation_SOURCES = import_interpolation.cpp
-import_interpolation_LDADD = ../../src/libpinyin_internal.la @GLIB2_LDFLAGS@
+import_interpolation_LDADD = ../../src/libpinyin_internal.la @GLIB2_LIBS@
export_interpolation_SOURCES = export_interpolation.cpp
-export_interpolation_LDADD = ../../src/libpinyin_internal.la @GLIB2_LDFLAGS@
+export_interpolation_LDADD = ../../src/libpinyin_internal.la @GLIB2_LIBS@
gen_chewing_table_SOURCES = gen_chewing_table.cpp
-gen_chewing_table_LDADD = ../../src/libpinyin_internal.la @GLIB2_LDFLAGS@
+gen_chewing_table_LDADD = ../../src/libpinyin_internal.la @GLIB2_LIBS@
diff --git a/utils/training/Makefile.am b/utils/training/Makefile.am
index 58119aa..dc834ec 100644
--- a/utils/training/Makefile.am
+++ b/utils/training/Makefile.am
@@ -22,7 +22,7 @@ INCLUDES = -I$(top_srcdir)/src \
-I$(top_srcdir)/src/storage \
-I$(top_srcdir)/src/lookup \
-I$(top_srcdir)/utils \
- @GLIB2_CPPFLAGS@
+ @GLIB2_CFLAGS@
noinst_HEADERS = k_mixture_model.h
@@ -43,55 +43,55 @@ noinst_PROGRAMS = gen_ngram \
gen_ngram_SOURCES = gen_ngram.cpp
-gen_ngram_LDADD = ../../src/libpinyin_internal.la @GLIB2_LDFLAGS@
+gen_ngram_LDADD = ../../src/libpinyin_internal.la @GLIB2_LIBS@
gen_deleted_ngram_SOURCES = gen_deleted_ngram.cpp
-gen_deleted_ngram_LDADD = ../../src/libpinyin_internal.la @GLIB2_LDFLAGS@
+gen_deleted_ngram_LDADD = ../../src/libpinyin_internal.la @GLIB2_LIBS@
gen_unigram_SOURCES = gen_unigram.cpp
-gen_unigram_LDADD = ../../src/libpinyin_internal.la @GLIB2_LDFLAGS@
+gen_unigram_LDADD = ../../src/libpinyin_internal.la @GLIB2_LIBS@
gen_k_mixture_model_SOURCES = gen_k_mixture_model.cpp
-gen_k_mixture_model_LDADD = ../../src/libpinyin_internal.la @GLIB2_LDFLAGS@
+gen_k_mixture_model_LDADD = ../../src/libpinyin_internal.la @GLIB2_LIBS@
estimate_interpolation_SOURCES = estimate_interpolation.cpp
-estimate_interpolation_LDADD = ../../src/libpinyin_internal.la @GLIB2_LDFLAGS@
+estimate_interpolation_LDADD = ../../src/libpinyin_internal.la @GLIB2_LIBS@
estimate_k_mixture_model_SOURCES = estimate_k_mixture_model.cpp
estimate_k_mixture_model_LDADD = ../../src/libpinyin_internal.la \
- @GLIB2_LDFLAGS@
+ @GLIB2_LIBS@
merge_k_mixture_model_SOURCES = merge_k_mixture_model.cpp
-merge_k_mixture_model_LDADD = ../../src/libpinyin_internal.la @GLIB2_LDFLAGS@
+merge_k_mixture_model_LDADD = ../../src/libpinyin_internal.la @GLIB2_LIBS@
prune_k_mixture_model_SOURCES = prune_k_mixture_model.cpp
-prune_k_mixture_model_LDADD = ../../src/libpinyin_internal.la @GLIB2_LDFLAGS@
+prune_k_mixture_model_LDADD = ../../src/libpinyin_internal.la @GLIB2_LIBS@
import_k_mixture_model_SOURCES = import_k_mixture_model.cpp
-import_k_mixture_model_LDADD = ../../src/libpinyin_internal.la @GLIB2_LDFLAGS@
+import_k_mixture_model_LDADD = ../../src/libpinyin_internal.la @GLIB2_LIBS@
export_k_mixture_model_SOURCES = export_k_mixture_model.cpp
-export_k_mixture_model_LDADD = ../../src/libpinyin_internal.la @GLIB2_LDFLAGS@
+export_k_mixture_model_LDADD = ../../src/libpinyin_internal.la @GLIB2_LIBS@
k_mixture_model_to_interpolation_SOURCES = k_mixture_model_to_interpolation.cpp
k_mixture_model_to_interpolation_LDADD = ../../src/libpinyin_internal.la \
- @GLIB2_LDFLAGS@
+ @GLIB2_LIBS@
validate_k_mixture_model_SOURCES = validate_k_mixture_model.cpp
validate_k_mixture_model_LDADD = ../../src/libpinyin_internal.la \
- @GLIB2_LDFLAGS@
+ @GLIB2_LIBS@
eval_correction_rate_SOURCES = eval_correction_rate.cpp
-eval_correction_rate_LDADD = ../../src/libpinyin_internal.la @GLIB2_LDFLAGS@
+eval_correction_rate_LDADD = ../../src/libpinyin_internal.la @GLIB2_LIBS@
--
1.8.1.2
From 1b52b36dde0fda71df328ea874431b2c4f424e04 Mon Sep 17 00:00:00 2001
From: Peng Wu <alexepico@gmail.com>
Date: Thu, 28 Feb 2013 12:32:46 +0800
Subject: [PATCH 2/2] fixes check_format
---
src/storage/phrase_index.h | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
src/pinyin.cpp | 10 ++++++++++
src/pinyin.h | 2 +-
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/src/storage/phrase_index.h b/src/storage/phrase_index.h
index acc7c4a..bc6aad2 100644
--- a/src/storage/phrase_index.h
+++ b/src/storage/phrase_index.h
@@ -147,16 +147,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;
diff --git a/src/pinyin.cpp b/src/pinyin.cpp
index e523119..4ad42a0 100644
--- a/src/pinyin.cpp
+++ b/src/pinyin.cpp
@@ -90,6 +90,16 @@ static bool check_format(const char * userdir){
}
--
1.8.1
From 095fbb86d0063dd22230c6aff879fd6eca745d2d Mon Sep 17 00:00:00 2001
From: Peng Wu <alexepico@gmail.com>
Date: Fri, 25 Jan 2013 12:16:19 +0800
Subject: [PATCH 2/2] fixes incomplete pinyin
---
src/storage/pinyin_phrase2.h | 22 ++++++++++++++++++----
1 file changed, 18 insertions(+), 4 deletions(-)
diff --git a/src/storage/pinyin_phrase2.h b/src/storage/pinyin_phrase2.h
index ba658f0..d5042aa 100644
--- a/src/storage/pinyin_phrase2.h
+++ b/src/storage/pinyin_phrase2.h
@@ -132,6 +132,10 @@ inline void compute_lower_value2(pinyin_option_t options,
* to check lower bound.
*/
+ /* as chewing zero middle is the first item, and its value is zero,
+ * no need to adjust it for incomplete pinyin.
+ */
filename = g_build_filename
+ (userdir, "user_pinyin_index.bin", NULL);
+ unlink(filename);
+ g_free(filename);
+
/* compute lower final */
sel = aKey.m_final;
for (k = aKey.m_final - 1; k >= CHEWING_ZERO_FINAL; --k) {
@@ -183,10 +187,20 @@ inline void compute_upper_value2(pinyin_option_t options,
}
aKey.m_initial = (ChewingInitial)sel;
- /* compute upper middle, skipped as no fuzzy pinyin here.
- * if needed in future, still use pinyin_compare_middle_and_final2
- * to check upper bound.
- */
+ /* adjust it for incomplete pinyin. */
+ filename = g_build_filename
+ (userdir, "user_phrase_index.bin", NULL);
+ unlink(filename);
+ g_free(filename);
+
+ /* compute upper middle */
+ sel = aKey.m_middle;
+ for (k = aKey.m_middle + 1; k <= CHEWING_LAST_MIDDLE; ++k) {
+ if (0 != pinyin_compare_middle_and_final2
+ (options,
+ (ChewingMiddle)aKey.m_middle, (ChewingMiddle)k,
+ (ChewingFinal)aKey.m_final, (ChewingFinal)aKey.m_final))
+ break;
+ else
+ sel = k;
+ }
+ aKey.m_middle = (ChewingMiddle)sel;
+ filename = g_build_filename
(userdir, "user.db", NULL);
unlink(filename);
g_free(filename);
diff --git a/src/pinyin.h b/src/pinyin.h
index 2f8a8db..0f57462 100644
--- a/src/pinyin.h
+++ b/src/pinyin.h
@@ -506,7 +506,7 @@ typedef ChewingKeyVector PinyinKeyVector;
typedef ChewingKeyRestVector PinyinKeyPosVector;
-#define LIBPINYIN_FORMAT_VERSION "0.8.0"
+#define LIBPINYIN_FORMAT_VERSION "0.8.1"
};
/* compute upper final */
sel = aKey.m_final;
--
1.8.1
1.8.1.2

View File

@ -1,8 +1,8 @@
%global snapshot 1
Name: libpinyin
Version: 0.8.0
Release: 3%{?dist}
Version: 0.8.1
Release: 1%{?dist}
Summary: Library to deal with pinyin
License: GPLv2+
@ -92,6 +92,10 @@ find $RPM_BUILD_ROOT -name '*.la' -exec rm -f {} ';'
%{_mandir}/man1/*.1.*
%changelog
* Thu Feb 28 2013 Peng Wu <pwu@redhat.com> - 0.8.1-1
- Update to 0.8.1
- Fixes pinyin_init crashes
* Mon Jan 28 2013 Peng Wu <pwu@redhat.com> - 0.8.0-3
- Fixes incomplete pinyin

View File

@ -1 +1 @@
d6d9648533517fbbd90360c7df07f0de libpinyin-0.8.0.tar.gz
c6e487ff641e8d7f55addff6b7b5285d libpinyin-0.8.1.tar.gz