Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Install mmseg etc. and their manpages to system.

Add notice for generating data files in doc/README.
Put data file in /usr/share/sunpinyin or so, wrt hier(7).
Remove redundant directories.
  • Loading branch information...
commit 47cc16596efb472037c7e52e415c909f201449cc 1 parent ce640d5
@CasperVector CasperVector authored
View
2  NEWS
@@ -16,7 +16,7 @@ libsunpinyin
* New LOGO!
* History cache focus more on recent commits.
-* Supports --libdir and --libdatadir as configuration arguments.
+* Supports --libdir and --datadir as configuration arguments.
* Hunpin support. (Contributed by Hanjie Xu)
* Fixed weird behavior of history with a single character.
* Fixed a potential issue for candidate ranking.
View
73 SConstruct
@@ -122,6 +122,42 @@ headers_plugin = [
'src/ime-core/imi_plugin.h',
]
+bins = [
+ 'src/mmseg',
+ 'src/slmseg',
+ 'src/ids2ngram',
+ 'src/idngram_merge',
+ 'src/slmbuild',
+ 'src/slmprune',
+ 'src/slminfo',
+ 'src/slmthread',
+ 'src/tslmendian',
+ 'src/tslminfo',
+ 'src/tslmpack',
+ 'src/genpyt',
+ 'src/getwordfreq',
+ ]
+
+mans = [
+ 'man/mmseg.1',
+ 'man/slmseg.1',
+ 'man/ids2ngram.1',
+ 'man/idngram_merge.1',
+ 'man/slmbuild.1',
+ 'man/slmprune.1',
+ 'man/slminfo.1',
+ 'man/slmthread.1',
+ 'man/tslmendian.1',
+ 'man/tslminfo.1',
+ 'man/tslmpack.1',
+ 'man/genpyt.1',
+ 'man/getwordfreq.1',
+ ]
+
+docs = [
+ 'doc/SLM.mk',
+ ]
+
# options
AddOption('--prefix', dest='prefix', metavar='DIR',
help='installation prefix')
@@ -129,8 +165,8 @@ AddOption('--prefix', dest='prefix', metavar='DIR',
AddOption('--libdir', dest='libdir', metavar='DIR',
help='installation libdir')
-AddOption('--libdatadir', dest='libdatadir', metavar='DIR',
- help='installation libdata dir')
+AddOption('--datadir', dest='datadir', metavar='DIR',
+ help='installation data dir')
AddOption('--rpath', dest='rpath', metavar='DIR',
help='encode rpath in the executables')
@@ -145,7 +181,7 @@ AddOption('--disable-plugins', dest='enable_plugins', action='store_false',
opts = Variables('configure.conf')
opts.Add('PREFIX', default='/usr/local')
opts.Add('LIBDIR', default='/usr/local/lib')
-opts.Add('LIBDATADIR', default='/usr/local/lib')
+opts.Add('DATADIR', default='/usr/local/share')
opts.Add('ENABLE_PLUGINS', default=False)
#
@@ -194,22 +230,25 @@ opts.Update(env)
if GetOption('prefix') is not None:
env['PREFIX'] = GetOption('prefix')
- env['LIBDATADIR'] = os.path.join(env['PREFIX'], 'lib')
env['LIBDIR'] = os.path.join(env['PREFIX'], 'lib')
+ env['DATADIR'] = os.path.join(env['PREFIX'], 'share')
if GetOption('libdir') is not None:
env['LIBDIR'] = GetOption('libdir')
-if GetOption('libdatadir') is not None:
- env['LIBDATADIR'] = GetOption('libdatadir')
+if GetOption('datadir') is not None:
+ env['DATADIR'] = GetOption('datadir')
env['ENABLE_PLUGINS'] = GetOption('enable_plugins')
opts.Save('configure.conf', env)
-libdir = env['LIBDIR']
-libdatadir = os.path.join(env['LIBDATADIR'], 'sunpinyin/data')
+bindir = os.path.join(env['PREFIX'], 'bin')
+mandir = os.path.join(env['PREFIX'], 'share/man')
+docdir = os.path.join(env['PREFIX'], 'share/doc/sunpinyin')
headersdir = os.path.join(env['PREFIX'], 'include/sunpinyin-2.0')
+datadir = os.path.join(env['DATADIR'], 'sunpinyin')
+libdir = env['LIBDIR']
# pass through environmental variables
envvar = [('CC', 'CC'),
@@ -229,7 +268,7 @@ if env['ENABLE_PLUGINS']:
# merge some of critical compile flags
env.MergeFlags(['-pipe -DHAVE_CONFIG_H',
- '-DSUNPINYIN_DATA_DIR=\\\'\\"%s\\"\\\'' % libdatadir])
+ '-DSUNPINYIN_DATA_DIR=\\\'\\"%s\\"\\\'' % datadir])
if GetOption('rpath') is not None and GetOS() != 'Darwin':
env.MergeFlags('-Wl,-R -Wl,%s' % GetOption('rpath'))
@@ -379,6 +418,7 @@ env.Command('src/pinyin/quanpin_trie.h', 'python/pinyin_data.py',
env.Object(slmsource)
SConscript(['src/SConscript'], exports='env')
+SConscript(['man/SConscript'], exports='env')
libname_default = '%ssunpinyin%s' % (env.subst('${SHLIBPREFIX}'),
env.subst('${SHLIBSUFFIX}'))
@@ -412,16 +452,19 @@ def DoInstall():
lib_pkgconfig_target = env.Install(os.path.join(libdir, 'pkgconfig'),
['sunpinyin-2.0.pc'])
- libdata_target = env.Install(libdatadir,
- ['data/lm_sc.t3g',
- 'data/pydict_sc.bin'])
+ bin_target = env.Install(bindir, bins)
+ man_target = env.Install(mandir, mans)
+ doc_target = env.Install(docdir, docs)
header_targets = []
for header in headers:
header_targets.append(env.InstallAs(headersdir + header[3:], header))
+ env.Alias('install-bin', bin_target)
+ env.Alias('install-man', man_target)
+ env.Alias('install-doc', doc_target)
env.Alias('install-headers', header_targets)
env.Alias('install-lib', lib_target + [lib_pkgconfig_target])
- env.Alias('install-libdata', libdata_target)
- env.Depends('install-libdata', 'install-lib')
+ Mkdir(datadir)
DoInstall()
-env.Alias('install', ['install-lib', 'install-libdata', 'install-headers'])
+env.Alias('install', ['install-bin', 'install-lib', 'install-headers'])
+
View
14 doc/README
@@ -0,0 +1,14 @@
+How to install data files for sunpinyin
+=======================================
+
+Get `lm_sc.t3g.arpa.tar.bz2' and `dict.utf8.tar.bz2' from [1],
+unpack them into some directory, and issue the following command in that
+directory:
+
+ make -f /path/to/SLM.mk data_bin
+
+Then copy generated `lm_sc.t3g' and `pydict3_sc.bin' to sunpinyin's data
+directory, usually /usr/share/sunpinyin/, and you are done.
+
+[1] https://code.google.com/p/open-gram/downloads
+
View
1  doc/SLM.mk
@@ -113,6 +113,7 @@ slm_bigram2: slm2_ids tslm2_info
slm_bigram3: slm3_ids tslm2_info
slm_trigram2: slm2_ids tslm3_info
slm_trigram3: slm3_ids tslm3_info
+data_bin: tslm3_pack lexicon3
bootstrap2:
make mmseg_bigram
View
124 doc/slm.mk
@@ -1,124 +0,0 @@
-DICT_FILE = dict.utf8
-CORPUS_FILE = corpus.utf8
-
-SLM_TARGET = lm_sc
-IDS_FILE = ${SLM_TARGET}.ids
-
-BIGRAM_STAT = ${SLM_TARGET}.id2gram
-SLM2_RAW_FILE = ${SLM_TARGET}.2gram
-SLM2_FILE = ${SLM_TARGET}.2gm
-SLM2_TEXT_FILE = ${SLM_TARGET}.2gm.arpa
-TSLM2_FILE = ${SLM_TARGET}.t2g
-TSLM2_TEXT_FILE = ${SLM_TARGET}.t2g.arpa
-
-TRIGRAM_STAT = ${SLM_TARGET}.id3gram
-SLM3_RAW_FILE = ${SLM_TARGET}.3gram
-SLM3_FILE = ${SLM_TARGET}.3gm
-SLM3_TEXT_FILE = ${SLM_TARGET}.3gm.arpa
-TSLM3_FILE = ${SLM_TARGET}.t3g
-TSLM3_TEXT_FILE = ${SLM_TARGET}.t3g.arpa
-
-PYTRIE2_FILE = pydict2_sc.bin
-PYTRIE2_LOG_FILE = pydict2_sc.log
-PYTRIE3_FILE = pydict3_sc.bin
-PYTRIE3_LOG_FILE = pydict3_sc.log
-
-all: bootstrap3
-
-mmseg_ids: ${DICT_FILE} ${CORPUS_FILE}
- mmseg -f bin -s 10 -a 9 -d ${DICT_FILE} ${CORPUS_FILE} > ${IDS_FILE}
-
-slm2_ids: ${DICT_FILE} ${CORPUS_FILE} ${TSLM2_FILE}
- slmseg -f bin -s 10 \
- -d ${DICT_FILE} -m ${TSLM2_FILE} ${CORPUS_FILE} > ${IDS_FILE}
-
-slm3_ids: ${DICT_FILE} ${CORPUS_FILE} ${TSLM3_FILE}
- slmseg -f bin -s 10 \
- -d ${DICT_FILE} -m ${TSLM3_FILE} ${CORPUS_FILE} > ${IDS_FILE}
-
-bigram_stat: ${BIGRAM_STAT_FILE}
-${BIGRAM_STAT_FILE}: ${IDS_FILE}
- ids2ngram -n 2 -p 20000000 -s $@.tmp -o $@ $<
- rm -f $@.tmp
-
-slm2_raw: ${SLM2_RAW_FILE}
-${SLM2_RAW_FILE}: ${BIGRAM_STAT_FILE}
- slmbuild -n 2 -w 200000 -c 0,2 -d ABS,0.005 -d ABS -b 10 -e 9 -o $@ $<
-
-slm2: ${SLM2_FILE}
-${SLM2_FILE}: ${SLM2_RAW_FILE}
- slmprune $< $@ R 100000 200000
-
-tslm2: ${TSLM2_FILE}
-${TSLM2_FILE}:${SLM2_FILE}
- slmthread $< $@
-
-lexicon2: ${PYTRIE2_FILE}
-${PYTRIE2_FILE}: ${DICT_FILE} ${TSLM_FILE2}
- genpyt -i ${DICT_FILE} -s ${TSLM_FILE2} -l ${PYTRIE2_LOG_FILE} -o $@
-
-slm2_info: ${SLM2_TEXT_FILE}
-${SLM2_TEXT_FILE}: ${DICT_FILE} ${SLM2_FILE}
- slminfo -p -v -l ${DICT_FILE} ${SLM2_FILE} > $@
-
-tslm2_info: ${TSLM2_TEXT_FILE}
-${TSLM2_TEXT_FILE}: ${DICT_FILE} ${TSLM2_FILE}
- tslminfo -v -l ${DICT_FILE} ${TSLM2_FILE} > $@
-
-tslm2_pack: ${DICT_FILE} ${TSLM2_TEXT_FILE}
- tslmpack ${TSLM2_TEXT_FILE} ${DICT_FILE} ${TSLM2_FILE}
-
-trigram_stat: ${TRIGRAM_STAT_FILE}
-${TRIGRAM_STAT_FILE}: ${IDS_FILE}
- ids2ngram -n 3 -p 20000000 -s $@.tmp -o $@ $<
- rm -f $@.tmp
-
-slm3_raw: ${SLM3_RAW_FILE}
-${SLM3_RAW_FILE}: ${TRIGRAM_STAT_FILE}
- slmbuild -n 3 -w 200000 -c 0,2,2 -d ABS,0.0005 -d ABS -d ABS -b 10 -e 9 \
- -o $@ $<
-slm3: ${SLM3_FILE}
-${SLM3_FILE}: ${SLM3_RAW_FILE}
- slmprune $< $@ R 100000 2500000 1000000
-
-tslm3: ${TSLM3_FILE}
-${TSLM3_FILE}: ${SLM3_FILE}
- slmthread $< $@
-
-slm3_info: ${SLM3_TEXT_FILE}
-${SLM3_TEXT_FILE}: ${DICT_FILE} ${SLM3_FILE}
- slminfo -p -v -l ${DICT_FILE} ${SLM3_FILE} > $@
-
-tslm3_info: ${TSLM3_TEXT_FILE}
-${TSLM3_TEXT_FILE}: ${DICT_FILE} ${TSLM3_FILE}
- tslminfo -p -v -l ${DICT_FILE} ${TSLM3_FILE} > $@
-
-tslm3_pack: ${DICT_FILE} ${TSLM3_TEXT_FILE}
- tslmpack ${TSLM3_TEXT_FILE} ${DICT_FILE} ${TSLM3_FILE}
-
-lexicon3: ${PYTRIE3_FILE}
-${PYTRIE3_FILE}: ${DICT_FILE} ${TSLM_FILE3}
- genpyt -i ${DICT_FILE} -s ${TSLM_FILE3} -l ${PYTRIE3_LOG_FILE} -o $@
-
-tmp_clean:
- rm -f *.tmp ${IDS_FILE}
- rm -f ${BIGRAM_STAT} ${SLM2_RAW_FILE}
- rm -f ${TRIGRAM_STAT} ${SLM3_RAW_FILE}
-
-mmseg_bigram: mmseg_ids tslm2_info
-mmseg_trigram: mmseg_ids tslm3_info
-slm_bigram2: slm2_ids tslm2_info
-slm_bigram3: slm3_ids tslm2_info
-slm_trigram2: slm2_ids tslm3_info
-slm_trigram3: slm3_ids tslm3_info
-
-bootstrap2:
- make mmseg_bigram
- make slm_bigram2
- make lexicon2
-
-bootstrap3:
- make mmseg_trigram
- make slm_trigram3
- make lexicon3
-
View
20 man/SConscript
@@ -0,0 +1,20 @@
+import os
+Import('env')
+
+pod2man = Builder(action = 'pod2man < $SOURCE > $TARGET')
+env.Append(BUILDERS = {'Man': pod2man})
+
+env.Man('mmseg.1', 'mmseg.pod')
+env.Man('slmseg.1', 'slmseg.pod')
+env.Man('ids2ngram.1', 'ids2ngram.pod')
+env.Man('idngram_merge.1', 'idngram_merge.pod')
+env.Man('slmbuild.1', 'slmbuild.pod')
+env.Man('slmprune.1', 'slmprune.pod')
+env.Man('slminfo.1', 'slminfo.pod')
+env.Man('slmthread.1', 'slmthread.pod')
+env.Man('tslmendian.1', 'tslmendian.pod')
+env.Man('tslminfo.1', 'tslminfo.pod')
+env.Man('tslmpack.1', 'tslmpack.pod')
+env.Man('genpyt.1', 'genpyt.pod')
+env.Man('getwordfreq.1', 'getwordfreq.pod')
+
View
0  doc/genpyt.pod → man/genpyt.pod
File renamed without changes
View
0  doc/getwordfreq.pod → man/getwordfreq.pod
File renamed without changes
View
0  doc/idngram_merge.pod → man/idngram_merge.pod
File renamed without changes
View
0  doc/ids2ngram.pod → man/ids2ngram.pod
File renamed without changes
View
0  doc/mmseg.pod → man/mmseg.pod
File renamed without changes
View
0  doc/slmbuild.pod → man/slmbuild.pod
File renamed without changes
View
0  doc/slminfo.pod → man/slminfo.pod
File renamed without changes
View
0  doc/slmprune.pod → man/slmprune.pod
File renamed without changes
View
0  doc/slmseg.pod → man/slmseg.pod
File renamed without changes
View
0  doc/slmthread.pod → man/slmthread.pod
File renamed without changes
View
0  doc/tslmendian.pod → man/tslmendian.pod
File renamed without changes
View
0  doc/tslminfo.pod → man/tslminfo.pod
File renamed without changes
View
0  doc/tslmpack.pod → man/tslmpack.pod
File renamed without changes
View
1  swap/README
@@ -1 +0,0 @@
-This is directory for temp result.
Please sign in to comment.
Something went wrong with that request. Please try again.