From 93ea00aa6c49fbf06de7a7490fe4c25d644443e0 Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Fri, 26 May 2017 14:58:22 +0800 Subject: import libzhuyin model --- configure.ac | 5 +---- data/Makefile.am | 1 + data/model/Makefile.am | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/Makefile.am | 2 +- src/ZYLibZhuyin.cc | 2 +- 5 files changed, 63 insertions(+), 6 deletions(-) create mode 100644 data/model/Makefile.am diff --git a/configure.ac b/configure.ac index b551c50..def9144 100644 --- a/configure.ac +++ b/configure.ac @@ -62,10 +62,6 @@ PKG_CHECK_MODULES(LIBZHUYIN, [ libzhuyin >= 1.0.91 ], [enable_libzhuyin=yes]) -LIBZHUYIN_DATADIR=`$PKG_CONFIG --variable=pkgdatadir libzhuyin` - -AC_SUBST(LIBZHUYIN_DATADIR) - # check opencc PKG_CHECK_MODULES(OPENCC, [opencc >= 1.0.0], [enable_opencc=yes]) @@ -123,6 +119,7 @@ setup/ibus-setup-libzhuyin ibus-libzhuyin.spec data/Makefile data/icons/Makefile +data/model/Makefile ]) AC_OUTPUT diff --git a/data/Makefile.am b/data/Makefile.am index 348fbff..69e6262 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -23,6 +23,7 @@ APPDATA_XML = libzhuyin.appdata.xml SUBDIRS = \ icons \ + model \ $(NULL) appdatadir = @datadir@/appdata diff --git a/data/model/Makefile.am b/data/model/Makefile.am new file mode 100644 index 0000000..f9ed87c --- /dev/null +++ b/data/model/Makefile.am @@ -0,0 +1,59 @@ +## Makefile.am -- Process this file with automake to produce Makefile.in +## Copyright (C) 2011 Peng Wu +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2, or (at your option) +## any later version. +## +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program; if not, write to the Free Software +## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + +tablefiles = tsi.table + +binfiles = ${tablefiles:.table=.bin} + + +textual_model_data = interpolation2.text \ + $(tablefiles) + + +binary_model_data = phrase_index.bin pinyin_index.bin \ + addon_phrase_index.bin addon_pinyin_index.bin \ + bigram.db \ + $(binfiles) + + +MAINTAINERCLEANFILES = Makefile.in + +EXTRA_DIST = $(textual_model_data) \ + table.conf + +model_db_DATA = $(binary_model_data) \ + table.conf + +model_dbdir = $(libdir)/ibus-libzhuyin/data + +CLEANFILES = $(binary_model_data) + +interpolation2.text: + wget http://downloads.sourceforge.net/libzhuyin/models/model10.text.tar.gz + tar xvf model10.text.tar.gz -C $(top_srcdir)/data/model + + +$(tablefiles) table.conf: interpolation2.text + +bigram.db: $(textual_model_data) + $(RM) $(binary_model_data) + gen_binary_files --table-dir $(top_srcdir)/data/model + import_interpolation --table-dir $(top_srcdir)/data/model < $(top_srcdir)/data/model/interpolation2.text + gen_unigram --table-dir $(top_srcdir)/data/model + +addon_phrase_index.bin addon_pinyin_index.bin phrase_index.bin pinyin_index.bin $(binfiles): bigram.db diff --git a/src/Makefile.am b/src/Makefile.am index b6590f7..07a4a70 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -101,7 +101,7 @@ ibus_engine_libzhuyin_CXXFLAGS = \ -DGETTEXT_PACKAGE=\"@GETTEXT_PACKAGE@\" \ -DPKGDATADIR=\"$(pkgdatadir)\" \ -DLIBEXECDIR=\"$(libexecdir)\" \ - -DLIBZHUYIN_DATADIR=\"@LIBZHUYIN_DATADIR@\/data\" \ + -DMODEL_DATADIR=\"$(libdir)\/ibus-libzhuyin\/data\" \ $(NULL) if HAVE_BOOST diff --git a/src/ZYLibZhuyin.cc b/src/ZYLibZhuyin.cc index 3d2084b..4208d56 100644 --- a/src/ZYLibZhuyin.cc +++ b/src/ZYLibZhuyin.cc @@ -63,7 +63,7 @@ LibZhuyinBackEnd::initZhuyinContext (Config *config) if (retval) { g_free (userdir); userdir = NULL; } - context = zhuyin_init (LIBZHUYIN_DATADIR, userdir); + context = zhuyin_init (MODEL_DATADIR, userdir); g_free (userdir); /* load user phrase library. */ -- cgit