From 2cec16b3635170d8e962562648abd356c47366d5 Mon Sep 17 00:00:00 2001 From: Kenneth Heafield Date: Mon, 22 Oct 2012 14:30:51 +0100 Subject: Add boost_system to continuous build --- .travis.yml | 1 + 1 file changed, 1 insertion(+) (limited to '.travis.yml') diff --git a/.travis.yml b/.travis.yml index 22d400aa..43d32b92 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,7 @@ before_script: - sudo apt-get install libboost-program-options-dev - sudo apt-get install libboost-regex-dev - sudo apt-get install libboost-test-dev + - sudo apt-get install libboost-system-dev - sudo apt-get install flex - autoreconf -ifv - ./configure -- cgit v1.2.3 From 6f36c1e0c7cab60a38c5905bc279dfdf9ef2c1fa Mon Sep 17 00:00:00 2001 From: Chris Dyer Date: Sun, 18 Nov 2012 14:02:17 -0500 Subject: add package dependency in auto build --- .travis.yml | 1 + 1 file changed, 1 insertion(+) (limited to '.travis.yml') diff --git a/.travis.yml b/.travis.yml index 43d32b92..cbfd8fb9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,6 @@ before_script: - sudo apt-get install libboost-program-options-dev + - sudo apt-get install libboost-serialization-dev - sudo apt-get install libboost-regex-dev - sudo apt-get install libboost-test-dev - sudo apt-get install libboost-system-dev -- cgit v1.2.3 From e9f80543bf7ff4070a1b5cdc1c3f5648addc70ce Mon Sep 17 00:00:00 2001 From: Victor Chahuneau Date: Sun, 18 Nov 2012 15:36:16 -0500 Subject: Add Python tests --- .travis.yml | 3 +++ python/tests/test_decoder.py | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 python/tests/test_decoder.py (limited to '.travis.yml') diff --git a/.travis.yml b/.travis.yml index cbfd8fb9..9e784717 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,3 +11,6 @@ script: make after_script: - make check - ./tests/run-system-tests.pl + - cd python + - python setup.py install + - nosetests tests diff --git a/python/tests/test_decoder.py b/python/tests/test_decoder.py new file mode 100644 index 00000000..a74e6268 --- /dev/null +++ b/python/tests/test_decoder.py @@ -0,0 +1,41 @@ +#coding:utf8 +import os +import gzip +import cdec +import unittest +from nose.tools import assert_almost_equals, assert_equal + +weights = os.path.dirname(__file__)+'/../../tests/system_tests/australia/weights' +ref_weights = {'WordPenalty': -2.844814, 'LanguageModel': 1.0, 'PhraseModel_0': -1.066893, 'PhraseModel_1': -0.752247, 'PhraseModel_2': -0.589793, 'PassThrough': -20.0, 'Glue': 0} + +grammar_file = os.path.dirname(__file__)+'/../../tests/system_tests/australia/australia.scfg.gz' + +input_sentence = u'澳洲 是 与 北韩 有 邦交 的 少数 国家 之一 。' +ref_output_sentence = u'australia is have diplomatic relations with north korea one of the few countries .' +ref_f_tree = u'(S (S (S (S (X 澳洲 是)) (X (X 与 北韩) 有 邦交)) (X 的 少数 国家 之一)) (X 。))' +ref_e_tree = u'(S (S (S (S (X australia is)) (X have diplomatic relations (X with north korea))) (X one of the few countries)) (X .))' +ref_fvector = {'PhraseModel_2': 7.082652, 'Glue': 3.0, 'PhraseModel_0': 2.014353, 'PhraseModel_1': 8.591477} + +def assert_fvector_equal(vec, ref): + vecd = dict(vec) + assert_equal(set(vecd.keys()), set(ref.keys())) + for k, v in ref.items(): + assert_almost_equals(vec[k], v, 6) + +class TestDecoder(unittest.TestCase): + def setUp(self): + self.decoder = cdec.Decoder(formalism='scfg') + self.decoder.read_weights(weights) + with gzip.open(grammar_file) as f: + self.grammar = f.read() + + def test_weights(self): + assert_fvector_equal(self.decoder.weights, ref_weights) + + def test_translate(self): + forest = self.decoder.translate(input_sentence, grammar=self.grammar) + assert_equal(forest.viterbi(), ref_output_sentence) + f_tree, e_tree = forest.viterbi_trees() + assert_equal(f_tree, ref_f_tree) + assert_equal(e_tree, ref_e_tree) + assert_fvector_equal(forest.viterbi_features(), ref_fvector) -- cgit v1.2.3 From 61ede617e3eaa15e0005965d1da2e462659b0f7d Mon Sep 17 00:00:00 2001 From: Victor Chahuneau Date: Sun, 18 Nov 2012 16:06:14 -0500 Subject: Switch .travis.yml language to python to get virtualenv --- .travis.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to '.travis.yml') diff --git a/.travis.yml b/.travis.yml index 9e784717..f3c418b5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,6 @@ +language: python +python: + - "2.7" before_script: - sudo apt-get install libboost-program-options-dev - sudo apt-get install libboost-serialization-dev @@ -7,10 +10,12 @@ before_script: - sudo apt-get install flex - autoreconf -ifv - ./configure -script: make +script: + - make + - cd python + - python setup.py install + - cd .. after_script: - make check - ./tests/run-system-tests.pl - - cd python - - python setup.py install - - nosetests tests + - nosetests python/tests -- cgit v1.2.3 From 38e6f00dcaaa09edfa156eb74bb19b8e1c474f8f Mon Sep 17 00:00:00 2001 From: Chris Dyer Date: Sat, 19 Jan 2013 19:21:24 -0500 Subject: new deps --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) (limited to '.travis.yml') diff --git a/.travis.yml b/.travis.yml index f3c418b5..14b625ab 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,9 @@ before_script: - sudo apt-get install libboost-regex-dev - sudo apt-get install libboost-test-dev - sudo apt-get install libboost-system-dev + - sudo apt-get install libboost-timer-dev + - sudo apt-get install libboost-chrono-dev + - sudo apt-get install libboost-thread-dev - sudo apt-get install flex - autoreconf -ifv - ./configure -- cgit v1.2.3 From eccb84332d9765a0c6afedc77ebdca60c83b249f Mon Sep 17 00:00:00 2001 From: Chris Dyer Date: Sat, 19 Jan 2013 19:46:46 -0500 Subject: deal with chrono/timer --- .travis.yml | 1 + configure.ac | 8 +++++--- python/setup.py.in | 4 ++-- 3 files changed, 8 insertions(+), 5 deletions(-) (limited to '.travis.yml') diff --git a/.travis.yml b/.travis.yml index 14b625ab..38dbd2fa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,7 @@ python: - "2.7" before_script: - sudo apt-get install libboost-program-options-dev + - sudo apt-cache search boost - sudo apt-get install libboost-serialization-dev - sudo apt-get install libboost-regex-dev - sudo apt-get install libboost-test-dev diff --git a/configure.ac b/configure.ac index a1e5ad84..c3e3251c 100644 --- a/configure.ac +++ b/configure.ac @@ -15,8 +15,10 @@ BOOST_REQUIRE([1.44]) BOOST_PROGRAM_OPTIONS BOOST_SYSTEM BOOST_SERIALIZATION -BOOST_CHRONO -BOOST_TIMER +if test $boost_major_version -ge 148; then + BOOST_CHRONO + BOOST_TIMER +fi BOOST_TEST BOOST_THREADS AM_PATH_PYTHON @@ -117,8 +119,8 @@ AC_CONFIG_FILES([klm/util/double-conversion/Makefile]) AC_CONFIG_FILES([klm/util/stream/Makefile]) AC_CONFIG_FILES([klm/util/Makefile]) AC_CONFIG_FILES([klm/lm/Makefile]) -AC_CONFIG_FILES([klm/lm/builder/Makefile]) AC_CONFIG_FILES([klm/search/Makefile]) +AC_CONFIG_FILES([klm/lm/builder/Makefile]) # training stuff AC_CONFIG_FILES([training/Makefile]) diff --git a/python/setup.py.in b/python/setup.py.in index fa8a9f5e..925cb196 100644 --- a/python/setup.py.in +++ b/python/setup.py.in @@ -3,7 +3,7 @@ from distutils.extension import Extension import re INC = ['..', 'src/', '../decoder', '../utils', '../mteval'] -LIB = ['../decoder', '../utils', '../mteval', '../training/utils', '../klm/lm', '../klm/util', '../klm/search'] +LIB = ['../decoder', '../utils', '../mteval', '../training/utils', '../klm/lm', '../klm/util', '../klm/util/double-conversion', '../klm/search'] # Set automatically by configure LIBS = re.findall('-l([^\s]+)', '@LIBS@') @@ -17,7 +17,7 @@ ext_modules = [ sources=['src/_cdec.cpp'], include_dirs=INC, library_dirs=LIB, - libraries=['cdec', 'utils', 'mteval', 'training_utils', 'klm', 'klm_util', 'ksearch'] + LIBS, + libraries=['cdec', 'utils', 'mteval', 'training_utils', 'klm', 'klm_util', 'klm_util_double', 'ksearch'] + LIBS, extra_compile_args=CPPFLAGS, extra_link_args=LDFLAGS), Extension(name='cdec.sa._sa', -- cgit v1.2.3 From d89ea1e829d5f5cd5bee092091739907c642181c Mon Sep 17 00:00:00 2001 From: Chris Dyer Date: Sat, 19 Jan 2013 19:49:56 -0500 Subject: newer versions of boost libs --- .travis.yml | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to '.travis.yml') diff --git a/.travis.yml b/.travis.yml index 38dbd2fa..c67c5b43 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,15 +2,14 @@ language: python python: - "2.7" before_script: - - sudo apt-get install libboost-program-options-dev - - sudo apt-cache search boost - - sudo apt-get install libboost-serialization-dev - - sudo apt-get install libboost-regex-dev - - sudo apt-get install libboost-test-dev - - sudo apt-get install libboost-system-dev - - sudo apt-get install libboost-timer-dev - - sudo apt-get install libboost-chrono-dev - - sudo apt-get install libboost-thread-dev + - sudo apt-get install libboost-program-options1.48-dev + - sudo apt-get install libboost-serialization1.48-dev + - sudo apt-get install libboost-regex1.48-dev + - sudo apt-get install libboost-test1.48-dev + - sudo apt-get install libboost-system1.48-dev + - sudo apt-get install libboost-timer1.48-dev + - sudo apt-get install libboost-chrono1.48-dev + - sudo apt-get install libboost-thread1.48-dev - sudo apt-get install flex - autoreconf -ifv - ./configure -- cgit v1.2.3 From 7cac43b858f3b681555bf0578f54b1f822c43207 Mon Sep 17 00:00:00 2001 From: Chris Dyer Date: Sun, 20 Jan 2013 10:08:57 -0500 Subject: remove dependency on timer/chrono --- .travis.yml | 2 -- configure.ac | 4 ---- klm/lm/builder/Makefile.am | 2 +- 3 files changed, 1 insertion(+), 7 deletions(-) (limited to '.travis.yml') diff --git a/.travis.yml b/.travis.yml index c67c5b43..d2d25903 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,8 +7,6 @@ before_script: - sudo apt-get install libboost-regex1.48-dev - sudo apt-get install libboost-test1.48-dev - sudo apt-get install libboost-system1.48-dev - - sudo apt-get install libboost-timer1.48-dev - - sudo apt-get install libboost-chrono1.48-dev - sudo apt-get install libboost-thread1.48-dev - sudo apt-get install flex - autoreconf -ifv diff --git a/configure.ac b/configure.ac index c474c050..402ddd0a 100644 --- a/configure.ac +++ b/configure.ac @@ -15,10 +15,6 @@ BOOST_REQUIRE([1.44]) BOOST_PROGRAM_OPTIONS BOOST_SYSTEM BOOST_SERIALIZATION -if test $boost_major_version -ge 148; then - BOOST_CHRONO - BOOST_TIMER -fi BOOST_TEST BOOST_THREADS AM_PATH_PYTHON diff --git a/klm/lm/builder/Makefile.am b/klm/lm/builder/Makefile.am index 00444256..b5c147fd 100644 --- a/klm/lm/builder/Makefile.am +++ b/klm/lm/builder/Makefile.am @@ -22,7 +22,7 @@ builder_SOURCES = \ print.hh \ sort.hh -builder_LDADD = ../libklm.a ../../util/double-conversion/libklm_util_double.a ../../util/stream/libklm_util_stream.a ../../util/libklm_util.a $(BOOST_TIMER_LIBS) $(BOOST_CHRONO_LIBS) $(BOOST_THREAD_LIBS) +builder_LDADD = ../libklm.a ../../util/double-conversion/libklm_util_double.a ../../util/stream/libklm_util_stream.a ../../util/libklm_util.a $(BOOST_THREAD_LIBS) AM_CPPFLAGS = -W -Wall -I$(top_srcdir)/klm -- cgit v1.2.3