From 95183b5760d7f168ae093ae8f9b29740628a278f Mon Sep 17 00:00:00 2001 From: Chris Dyer Date: Tue, 3 Mar 2015 01:14:07 -0500 Subject: migration to cmake --- training/mira/CMakeLists.txt | 17 +++++++++++++++++ training/mira/Makefile.am | 20 -------------------- 2 files changed, 17 insertions(+), 20 deletions(-) create mode 100644 training/mira/CMakeLists.txt delete mode 100644 training/mira/Makefile.am (limited to 'training/mira') diff --git a/training/mira/CMakeLists.txt b/training/mira/CMakeLists.txt new file mode 100644 index 00000000..3a8fa516 --- /dev/null +++ b/training/mira/CMakeLists.txt @@ -0,0 +1,17 @@ +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../utils) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../utils) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../mteval) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../decoder) + +set(kbest_mira_SRCS kbest_mira.cc) +add_executable(kbest_mira ${kbest_mira_SRCS}) +target_link_libraries(kbest_mira ${KDE4_KDECORE_LIBS} libcdec ksearch mteval utils klm klm_util klm_util_double ${Boost_LIBRARIES} z) + +set(kbest_cut_mira_SRCS kbest_cut_mira.cc) +add_executable(kbest_cut_mira ${kbest_cut_mira_SRCS}) +target_link_libraries(kbest_cut_mira ${KDE4_KDECORE_LIBS} libcdec ksearch mteval utils klm klm_util klm_util_double ${Boost_LIBRARIES} z) + +set(ada_opt_sm_SRCS ada_opt_sm.cc) +add_executable(ada_opt_sm ${ada_opt_sm_SRCS}) +target_link_libraries(ada_opt_sm ${KDE4_KDECORE_LIBS} training_utils libcdec ksearch mteval utils klm klm_util klm_util_double ${Boost_LIBRARIES} z) + diff --git a/training/mira/Makefile.am b/training/mira/Makefile.am deleted file mode 100644 index a318cf6e..00000000 --- a/training/mira/Makefile.am +++ /dev/null @@ -1,20 +0,0 @@ -bin_PROGRAMS = \ - kbest_mira \ - kbest_cut_mira \ - ada_opt_sm - -EXTRA_DIST = mira.py - -ada_opt_sm_SOURCES = ada_opt_sm.cc -ada_opt_sm_LDFLAGS= -rdynamic -ada_opt_sm_LDADD = ../utils/libtraining_utils.a ../../decoder/libcdec.a ../../klm/search/libksearch.a ../../mteval/libmteval.a ../../utils/libutils.a ../../klm/lm/libklm.a ../../klm/util/libklm_util.a ../../klm/util/double-conversion/libklm_util_double.a - -kbest_mira_SOURCES = kbest_mira.cc -kbest_mira_LDFLAGS= -rdynamic -kbest_mira_LDADD = ../../decoder/libcdec.a ../../klm/search/libksearch.a ../../mteval/libmteval.a ../../utils/libutils.a ../../klm/lm/libklm.a ../../klm/util/libklm_util.a ../../klm/util/double-conversion/libklm_util_double.a - -kbest_cut_mira_SOURCES = kbest_cut_mira.cc -kbest_cut_mira_LDFLAGS= -rdynamic -kbest_cut_mira_LDADD = ../../decoder/libcdec.a ../../klm/search/libksearch.a ../../mteval/libmteval.a ../../utils/libutils.a ../../klm/lm/libklm.a ../../klm/util/libklm_util.a ../../klm/util/double-conversion/libklm_util_double.a - -AM_CPPFLAGS = -W -Wall -Wno-sign-compare -I$(top_srcdir)/utils -I$(top_srcdir)/decoder -I$(top_srcdir)/mteval -I$(top_srcdir)/training/utils -- cgit v1.2.3 From 06f1b6aedbd96d652d5337cf1b93b51e4dd9a620 Mon Sep 17 00:00:00 2001 From: Chris Dyer Date: Wed, 4 Mar 2015 21:36:51 -0500 Subject: remove perfect hash function stuff, add zip option to extract.cc --- extractor/CMakeLists.txt | 17 ++++++++++---- extractor/extract.cc | 14 ++++++++---- training/mira/mira.py | 59 +++++++++++++++++++++++------------------------- utils/CMakeLists.txt | 1 - utils/perfect_hash.cc | 37 ------------------------------ utils/perfect_hash.h | 27 ---------------------- utils/phmt.cc | 42 ---------------------------------- 7 files changed, 49 insertions(+), 148 deletions(-) delete mode 100644 utils/perfect_hash.cc delete mode 100644 utils/perfect_hash.h delete mode 100644 utils/phmt.cc (limited to 'training/mira') diff --git a/extractor/CMakeLists.txt b/extractor/CMakeLists.txt index d37c6b95..1cf8533b 100644 --- a/extractor/CMakeLists.txt +++ b/extractor/CMakeLists.txt @@ -1,9 +1,17 @@ -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../utils) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/features) -find_package(GTest) -find_package(GMock) +find_package(OpenMP) +if (OPENMP_FOUND) + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") +endif() + +find_package(GTest REQUIRED) +find_package(GMock REQUIRED) if(GMOCK_FOUND) + #rule_factory_test.cc set(TEST_SRCS alignment_test.cc data_array_test.cc fast_intersector_test.cc @@ -15,7 +23,6 @@ if(GMOCK_FOUND) precomputation_test.cc rule_extractor_helper_test.cc rule_extractor_test.cc - rule_factory_test.cc scorer2_test.cc suffix_array_sampler_test.cc suffix_array_test.cc @@ -56,7 +63,7 @@ target_link_libraries(run_extractor extractor ${Boost_LIBRARIES} z) set(extract_SRCS extract.cc) add_executable(extract ${extract_SRCS}) -target_link_libraries(extract extractor ${Boost_LIBRARIES} z) +target_link_libraries(extract extractor utils ${Boost_LIBRARIES} z) set(extractor_STAT_SRCS diff --git a/extractor/extract.cc b/extractor/extract.cc index e5b6f6ff..08f209cc 100644 --- a/extractor/extract.cc +++ b/extractor/extract.cc @@ -14,6 +14,7 @@ const unsigned omp_get_num_threads() { return 1; } #endif +#include "filelib.h" #include "alignment.h" #include "data_array.h" #include "features/count_source_target.h" @@ -42,8 +43,8 @@ using namespace features; using namespace std; // Returns the file path in which a given grammar should be written. -fs::path GetGrammarFilePath(const fs::path& grammar_path, int file_number) { - string file_name = "grammar." + to_string(file_number); +fs::path GetGrammarFilePath(const fs::path& grammar_path, int file_number, bool use_zip) { + string file_name = "grammar." + to_string(file_number) + (use_zip ? ".gz" : ""); return grammar_path / file_name; } @@ -58,6 +59,7 @@ int main(int argc, char** argv) { ("threads,t", po::value()->required()->default_value(1), threads_option.c_str()) ("grammars,g", po::value()->required(), "Grammars output path") + ("gzip,z", "Gzip grammars") ("max_rule_span", po::value()->default_value(15), "Maximum rule span") ("max_rule_symbols", po::value()->default_value(5), @@ -205,12 +207,14 @@ int main(int argc, char** argv) { vm["max_rule_symbols"].as(), vm["max_samples"].as(), vm["tight_phrases"].as()); + const bool use_zip = vm.count("gzip"); // Creates the grammars directory if it doesn't exist. fs::path grammar_path = vm["grammars"].as(); if (!fs::is_directory(grammar_path)) { fs::create_directory(grammar_path); } + grammar_path = fs::canonical(grammar_path); // Reads all sentences for which we extract grammar rules (the paralellization // is simplified if we read all sentences upfront). @@ -239,12 +243,12 @@ int main(int argc, char** argv) { } Grammar grammar = extractor.GetGrammar( sentences[i], blacklisted_sentence_ids); - ofstream output(GetGrammarFilePath(grammar_path, i).c_str()); - output << grammar; + WriteFile wf(GetGrammarFilePath(grammar_path, i, use_zip).c_str()); + *wf.stream() << grammar; } for (size_t i = 0; i < sentences.size(); ++i) { - cout << " " << sentences[i] << " " << suffixes[i] << endl; } diff --git a/training/mira/mira.py b/training/mira/mira.py index ec9c2d64..ccecb10e 100755 --- a/training/mira/mira.py +++ b/training/mira/mira.py @@ -5,12 +5,6 @@ import argparse import logging import random, time import gzip, itertools -try: - import cdec.score -except ImportError: - sys.stderr.write('Could not import pycdec, see cdec/python/README.md for details\n') - sys.exit(1) -have_mpl = True try: import matplotlib matplotlib.use('Agg') @@ -19,26 +13,33 @@ except ImportError: have_mpl = False #mira run script -#requires pycdec to be built, since it is used for scoring hypothesis -#translations. #matplotlib must be installed for graphing to work #email option requires mail +script_dir = os.path.dirname(os.path.abspath(sys.argv[0])) +fast_score_binary = script_dir+'/../../mteval/fast_score' +dlog = None + #scoring function using pycdec scoring def fast_score(hyps, refs, metric): - scorer = cdec.score.Scorer(metric) - logging.info('loaded {0} references for scoring with {1}'.format( - len(refs), metric)) - if metric=='BLEU': - logging.warning('BLEU is ambiguous, assuming IBM_BLEU\n') - metric = 'IBM_BLEU' - elif metric=='COMBI': - logging.warning('COMBI metric is no longer supported, switching to ' - 'COMB:TER=-0.5;BLEU=0.5') - metric = 'COMB:TER=-0.5;BLEU=0.5' - stats = sum(scorer(r).evaluate(h) for h,r in itertools.izip(hyps,refs)) - logging.info('Score={} ({})'.format(stats.score, stats.detail)) - return stats.score + #scorer = cdec.score.Scorer(metric) + #logging.info('loaded {0} references for scoring with {1}'.format( + # len(refs), metric)) + #if metric=='BLEU': + # logging.warning('BLEU is ambiguous, assuming IBM_BLEU\n') + # metric = 'IBM_BLEU' + #elif metric=='COMBI': + # logging.warning('COMBI metric is no longer supported, switching to ' + # 'COMB:TER=-0.5;BLEU=0.5') + # metric = 'COMB:TER=-0.5;BLEU=0.5' + #stats = sum(scorer(r).evaluate(h) for h,r in itertools.izip(hyps,refs)) + #logging.info('Score={} ({})'.format(stats.score, stats.detail)) + #return stats.score + cmd = ('{0} -r{1} -i {2} -m {3}').format(fast_score_binary, refs, hyps, metric) + proc = subprocess.Popen(shlex.split(cmd), stdout=subprocess.PIPE) + o = proc.stdout.readline().strip() + print 'res: ', o + return float(o) #create new parallel input file in output directory in sgml format def enseg(devfile, newfile, gprefix): @@ -81,7 +82,6 @@ def enseg(devfile, newfile, gprefix): def main(): #set logging to write all info messages to stderr logging.basicConfig(level=logging.INFO) - script_dir = os.path.dirname(os.path.abspath(sys.argv[0])) if not have_mpl: logging.warning('Failed to import matplotlib, graphs will not be generated.') @@ -373,7 +373,8 @@ def optimize(args, script_dir, dev_size): cmd = parallel_cmd + ' ' + decoder_cmd logging.info('OPTIMIZATION COMMAND: {}'.format(cmd)) - + + global dlog dlog = open(decoderlog,'w') runf = open(runfile,'w') retries = 0 @@ -420,7 +421,7 @@ def optimize(args, script_dir, dev_size): bests = [] fears = [] for line in run: - hope, best, fear = line.split(' ||| ') + hope, best, fear = line.strip().split(' ||| ') hopes.append(hope) bests.append(best) fears.append(fear) @@ -436,14 +437,10 @@ def optimize(args, script_dir, dev_size): gzip_file(runfile) gzip_file(decoderlog) - ref_file = open(refs) - references = [line.split(' ||| ') for line in - ref_file.read().strip().split('\n')] - ref_file.close() #get score for best hypothesis translations, hope and fear translations - dec_score = fast_score(bests, references, args.metric) - dec_score_h = fast_score(hopes, references, args.metric) - dec_score_f = fast_score(fears, references, args.metric) + dec_score = fast_score(runfile+'.B', refs, args.metric) + dec_score_h = fast_score(runfile+'.H', refs, args.metric) + dec_score_f = fast_score(runfile+'.F', refs, args.metric) hope_best_fear['hope'].append(dec_score) hope_best_fear['best'].append(dec_score_h) diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt index 17436263..59fb644d 100644 --- a/utils/CMakeLists.txt +++ b/utils/CMakeLists.txt @@ -70,7 +70,6 @@ set(utils_STAT_SRCS named_enum.h null_deleter.h null_traits.h - perfect_hash.h prob.h sampler.h semiring.h diff --git a/utils/perfect_hash.cc b/utils/perfect_hash.cc deleted file mode 100644 index 706e2741..00000000 --- a/utils/perfect_hash.cc +++ /dev/null @@ -1,37 +0,0 @@ -#include "config.h" - -#ifdef HAVE_CMPH - -#include "perfect_hash.h" - -#include -#include - -using namespace std; - -PerfectHashFunction::~PerfectHashFunction() { - cmph_destroy(mphf_); -} - -PerfectHashFunction::PerfectHashFunction(const string& fname) { - FILE* f = fopen(fname.c_str(), "r"); - if (!f) { - cerr << "Failed to open file " << fname << " for reading: cannot load hash function.\n"; - abort(); - } - mphf_ = cmph_load(f); - if (!mphf_) { - cerr << "cmph_load failed on " << fname << "!\n"; - abort(); - } -} - -size_t PerfectHashFunction::operator()(const string& key) const { - return cmph_search(mphf_, &key[0], key.size()); -} - -size_t PerfectHashFunction::number_of_keys() const { - return cmph_size(mphf_); -} - -#endif diff --git a/utils/perfect_hash.h b/utils/perfect_hash.h deleted file mode 100644 index 8c12c9f0..00000000 --- a/utils/perfect_hash.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef PERFECT_HASH_MAP_H_ -#define PERFECT_HASH_MAP_H_ - -#include -#include - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#ifdef HAVE_CMPH -#include "cmph.h" -#endif - -class PerfectHashFunction : boost::noncopyable { - public: - explicit PerfectHashFunction(const std::string& fname); - ~PerfectHashFunction(); - size_t operator()(const std::string& key) const; - size_t number_of_keys() const; - private: -#ifdef HAVE_CMPH - cmph_t *mphf_; -#endif -}; - -#endif diff --git a/utils/phmt.cc b/utils/phmt.cc deleted file mode 100644 index b17febf6..00000000 --- a/utils/phmt.cc +++ /dev/null @@ -1,42 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#ifndef HAVE_CMPH -int main() { - return 0; -} -#else - -#include -#include "weights.h" -#include "fdict.h" - -using namespace std; - -int main(int argc, char** argv) { - if (argc != 2) { cerr << "Usage: " << argv[0] << " file.mphf\n"; return 1; } - FD::EnableHash(argv[1]); - cerr << "Number of keys: " << FD::NumFeats() << endl; - cerr << "LexFE = " << FD::Convert("LexFE") << endl; - cerr << "LexEF = " << FD::Convert("LexEF") << endl; - { - vector v(FD::NumFeats()); - v[FD::Convert("LexFE")] = 1.0; - v[FD::Convert("LexEF")] = 0.5; - cerr << "Writing...\n"; - Weights::WriteToFile("weights.bin", v); - cerr << "Done.\n"; - } - { - vector v(FD::NumFeats()); - cerr << "Reading...\n"; - Weights::InitFromFile("weights.bin", &v); - cerr << "Done.\n"; - assert(v[FD::Convert("LexFE")] == 1.0); - assert(v[FD::Convert("LexEF")] == 0.5); - } -} - -#endif - -- cgit v1.2.3 From 42e6a2888f986b062c6391b6bef6ef817c6b8a68 Mon Sep 17 00:00:00 2001 From: Chris Dyer Date: Wed, 4 Mar 2015 22:46:33 -0500 Subject: deal with libdl --- .gitignore | 1 + CMakeLists.txt | 1 + cmake/FindLibDL.cmake | 30 ++++++++++++++++++++++++++++++ decoder/CMakeLists.txt | 4 +++- extractor/CMakeLists.txt | 10 ++++++---- training/crf/CMakeLists.txt | 22 ++++++++-------------- training/dtrain/CMakeLists.txt | 2 +- training/latent_svm/CMakeLists.txt | 2 +- training/mira/CMakeLists.txt | 7 +++---- training/utils/CMakeLists.txt | 6 ++++-- utils/CMakeLists.txt | 2 +- 11 files changed, 59 insertions(+), 28 deletions(-) create mode 100644 cmake/FindLibDL.cmake (limited to 'training/mira') diff --git a/.gitignore b/.gitignore index 81ede92e..07145db9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +example_extff/libff_example.so* Testing/ */Testing/ training/Testing/ diff --git a/CMakeLists.txt b/CMakeLists.txt index 21c2a230..934c69e6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,6 +11,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}) #### packages find_package(ZLIB REQUIRED) find_package(BZip2 REQUIRED) +find_package(LibDL REQUIRED) # for pycdec find_package(PythonInterp 2.7 REQUIRED) diff --git a/cmake/FindLibDL.cmake b/cmake/FindLibDL.cmake new file mode 100644 index 00000000..1689e4c7 --- /dev/null +++ b/cmake/FindLibDL.cmake @@ -0,0 +1,30 @@ +# - Find libdl +# Find the native LIBDL includes and library +# +# LIBDL_INCLUDE_DIR - where to find dlfcn.h, etc. +# LIBDL_LIBRARIES - List of libraries when using libdl. +# LIBDL_FOUND - True if libdl found. + + +IF (LIBDL_INCLUDE_DIR) + # Already in cache, be silent + SET(LIBDL_FIND_QUIETLY TRUE) +ENDIF (LIBDL_INCLUDE_DIR) + +FIND_PATH(LIBDL_INCLUDE_DIR dlfcn.h) + +SET(LIBDL_NAMES dl libdl ltdl libltdl) +FIND_LIBRARY(LIBDL_LIBRARY NAMES ${LIBDL_NAMES} ) + +# handle the QUIETLY and REQUIRED arguments and set LIBDL_FOUND to TRUE if +# all listed variables are TRUE +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibDL DEFAULT_MSG LIBDL_LIBRARY LIBDL_INCLUDE_DIR) + +IF(LIBDL_FOUND) + SET( LIBDL_LIBRARIES ${LIBDL_LIBRARY} ) +ELSE(LIBDL_FOUND) + SET( LIBDL_LIBRARIES ) +ENDIF(LIBDL_FOUND) + +MARK_AS_ADVANCED( LIBDL_LIBRARY LIBDL_INCLUDE_DIR ) diff --git a/decoder/CMakeLists.txt b/decoder/CMakeLists.txt index 591ab7b3..f7683887 100644 --- a/decoder/CMakeLists.txt +++ b/decoder/CMakeLists.txt @@ -3,6 +3,8 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../mteval) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../klm) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/..) +set(CMAKE_POSITION_INDEPENDENT_CODE ON) + PROJECT(decoder C CXX) find_package(FLEX REQUIRED) @@ -145,7 +147,7 @@ add_library(libcdec STATIC ${libcdec_SRCS}) set(cdec_SRCS cdec.cc) add_executable(cdec ${cdec_SRCS}) -target_link_libraries(cdec libcdec mteval utils ksearch klm klm_util klm_util_double ${Boost_LIBRARIES} ${ZLIB_LIBRARIES}) +target_link_libraries(cdec libcdec mteval utils ksearch klm klm_util klm_util_double ${Boost_LIBRARIES} ${ZLIB_LIBRARIES} ${LIBDL_LIBRARIES}) set(TEST_SRCS grammar_test.cc diff --git a/extractor/CMakeLists.txt b/extractor/CMakeLists.txt index 1cf8533b..93a524cc 100644 --- a/extractor/CMakeLists.txt +++ b/extractor/CMakeLists.txt @@ -8,9 +8,10 @@ if (OPENMP_FOUND) set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") endif() -find_package(GTest REQUIRED) -find_package(GMock REQUIRED) -if(GMOCK_FOUND) +find_package(GTest) +find_package(GMock) +if(GTEST_FOUND) + if(GMOCK_FOUND) #rule_factory_test.cc set(TEST_SRCS alignment_test.cc data_array_test.cc @@ -50,7 +51,8 @@ if(GMOCK_FOUND) add_test(NAME ${testName} COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/${testName} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) endforeach(testSrc) -endif(GMOCK_FOUND) + endif(GMOCK_FOUND) +endif(GTEST_FOUND) set(sacompile_SRCS sacompile.cc) add_executable(sacompile ${sacompile_SRCS}) diff --git a/training/crf/CMakeLists.txt b/training/crf/CMakeLists.txt index 4792983e..85fab7a0 100644 --- a/training/crf/CMakeLists.txt +++ b/training/crf/CMakeLists.txt @@ -9,7 +9,7 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../decoder) set(mpi_batch_optimize_SRCS mpi_batch_optimize.cc cllh_observer.cc cllh_observer.h) add_executable(mpi_batch_optimize ${mpi_batch_optimize_SRCS}) -target_link_libraries(mpi_batch_optimize training_utils libcdec ksearch mteval utils klm klm_util klm_util_double ${Boost_LIBRARIES} z) +target_link_libraries(mpi_batch_optimize training_utils libcdec ksearch mteval utils klm klm_util klm_util_double ${Boost_LIBRARIES} z ${LIBDL_LIBRARIES}) ########### next target ############### @@ -17,8 +17,7 @@ set(mpi_adagrad_optimize_SRCS mpi_adagrad_optimize.cc cllh_observer.cc cllh_obse add_executable(mpi_adagrad_optimize ${mpi_adagrad_optimize_SRCS}) -target_link_libraries(mpi_adagrad_optimize ${KDE4_KDECORE_LIBS} training_utils libcdec ksearch mteval utils klm klm_util klm_util_double ${Boost_LIBRARIES} z) - +target_link_libraries(mpi_adagrad_optimize ${KDE4_KDECORE_LIBS} training_utils libcdec ksearch mteval utils klm klm_util klm_util_double ${Boost_LIBRARIES} z ${LIBDL_LIBRARIES}) ########### next target ############### @@ -27,8 +26,7 @@ set(mpi_compute_cllh_SRCS mpi_compute_cllh.cc cllh_observer.cc cllh_observer.h) add_executable(mpi_compute_cllh ${mpi_compute_cllh_SRCS}) -target_link_libraries(mpi_compute_cllh ${KDE4_KDECORE_LIBS} libcdec ksearch mteval utils klm klm_util klm_util_double ${Boost_LIBRARIES} z) - +target_link_libraries(mpi_compute_cllh ${KDE4_KDECORE_LIBS} libcdec ksearch mteval utils klm klm_util klm_util_double ${Boost_LIBRARIES} z ${LIBDL_LIBRARIES}) ########### next target ############### @@ -37,8 +35,7 @@ set(mpi_extract_features_SRCS mpi_extract_features.cc) add_executable(mpi_extract_features ${mpi_extract_features_SRCS}) -target_link_libraries(mpi_extract_features ${KDE4_KDECORE_LIBS} libcdec ksearch mteval utils klm klm_util klm_util_double ${Boost_LIBRARIES} z) - +target_link_libraries(mpi_extract_features ${KDE4_KDECORE_LIBS} libcdec ksearch mteval utils klm klm_util klm_util_double ${Boost_LIBRARIES} z ${LIBDL_LIBRARIES}) ########### next target ############### @@ -47,8 +44,7 @@ set(mpi_extract_reachable_SRCS mpi_extract_reachable.cc) add_executable(mpi_extract_reachable ${mpi_extract_reachable_SRCS}) -target_link_libraries(mpi_extract_reachable ${KDE4_KDECORE_LIBS} libcdec ksearch mteval utils klm klm_util klm_util_double ${Boost_LIBRARIES} z) - +target_link_libraries(mpi_extract_reachable ${KDE4_KDECORE_LIBS} libcdec ksearch mteval utils klm klm_util klm_util_double ${Boost_LIBRARIES} z ${LIBDL_LIBRARIES}) ########### next target ############### @@ -56,8 +52,7 @@ set(mpi_flex_optimize_SRCS mpi_flex_optimize.cc) add_executable(mpi_flex_optimize ${mpi_flex_optimize_SRCS}) -target_link_libraries(mpi_flex_optimize ${KDE4_KDECORE_LIBS} training_utils libcdec ksearch mteval utils klm klm_util klm_util_double ${Boost_LIBRARIES} z) - +target_link_libraries(mpi_flex_optimize ${KDE4_KDECORE_LIBS} training_utils libcdec ksearch mteval utils klm klm_util klm_util_double ${Boost_LIBRARIES} z ${LIBDL_LIBRARIES}) ########### next target ############### @@ -65,7 +60,7 @@ set(mpi_online_optimize_SRCS mpi_online_optimize.cc) add_executable(mpi_online_optimize ${mpi_online_optimize_SRCS}) -target_link_libraries(mpi_online_optimize ${KDE4_KDECORE_LIBS} training_utils libcdec ksearch mteval utils klm klm_util klm_util_double ${Boost_LIBRARIES} z) +target_link_libraries(mpi_online_optimize ${KDE4_KDECORE_LIBS} training_utils libcdec ksearch mteval utils klm klm_util klm_util_double ${Boost_LIBRARIES} z ${LIBDL_LIBRARIES}) ########### next target ############### @@ -73,6 +68,5 @@ set(mpi_baum_welch_SRCS mpi_baum_welch.cc) add_executable(mpi_baum_welch ${mpi_baum_welch_SRCS}) -target_link_libraries(mpi_baum_welch ${KDE4_KDECORE_LIBS} libcdec ksearch mteval utils klm klm_util klm_util_double ${Boost_LIBRARIES} z) - +target_link_libraries(mpi_baum_welch ${KDE4_KDECORE_LIBS} libcdec ksearch mteval utils klm klm_util klm_util_double ${Boost_LIBRARIES} z ${LIBDL_LIBRARIES}) diff --git a/training/dtrain/CMakeLists.txt b/training/dtrain/CMakeLists.txt index 653cfe2b..72e80b6b 100644 --- a/training/dtrain/CMakeLists.txt +++ b/training/dtrain/CMakeLists.txt @@ -12,4 +12,4 @@ set(dtrain_SRCS pairsampling.h score.h) add_executable(dtrain ${dtrain_SRCS}) -target_link_libraries(dtrain libcdec ksearch mteval utils klm klm_util klm_util_double ${Boost_LIBRARIES} z) +target_link_libraries(dtrain libcdec ksearch mteval utils klm klm_util klm_util_double ${Boost_LIBRARIES} z ${LIBDL_LIBRARIES}) diff --git a/training/latent_svm/CMakeLists.txt b/training/latent_svm/CMakeLists.txt index ec48e02f..332b8d42 100644 --- a/training/latent_svm/CMakeLists.txt +++ b/training/latent_svm/CMakeLists.txt @@ -5,4 +5,4 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../decoder) set(latent_svm_SRCS latent_svm.cc) add_executable(latent_svm ${latent_svm_SRCS}) -target_link_libraries(latent_svm libcdec ksearch mteval utils klm klm_util klm_util_double ${Boost_LIBRARIES} z) +target_link_libraries(latent_svm libcdec ksearch mteval utils klm klm_util klm_util_double ${Boost_LIBRARIES} z ${LIBDL_LIBRARIES}) diff --git a/training/mira/CMakeLists.txt b/training/mira/CMakeLists.txt index 3a8fa516..bba9ef5f 100644 --- a/training/mira/CMakeLists.txt +++ b/training/mira/CMakeLists.txt @@ -5,13 +5,12 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../decoder) set(kbest_mira_SRCS kbest_mira.cc) add_executable(kbest_mira ${kbest_mira_SRCS}) -target_link_libraries(kbest_mira ${KDE4_KDECORE_LIBS} libcdec ksearch mteval utils klm klm_util klm_util_double ${Boost_LIBRARIES} z) +target_link_libraries(kbest_mira libcdec ksearch mteval utils klm klm_util klm_util_double ${Boost_LIBRARIES} z ${LIBDL_LIBRARIES}) set(kbest_cut_mira_SRCS kbest_cut_mira.cc) add_executable(kbest_cut_mira ${kbest_cut_mira_SRCS}) -target_link_libraries(kbest_cut_mira ${KDE4_KDECORE_LIBS} libcdec ksearch mteval utils klm klm_util klm_util_double ${Boost_LIBRARIES} z) +target_link_libraries(kbest_cut_mira libcdec ksearch mteval utils klm klm_util klm_util_double ${Boost_LIBRARIES} z ${LIBDL_LIBRARIES}) set(ada_opt_sm_SRCS ada_opt_sm.cc) add_executable(ada_opt_sm ${ada_opt_sm_SRCS}) -target_link_libraries(ada_opt_sm ${KDE4_KDECORE_LIBS} training_utils libcdec ksearch mteval utils klm klm_util klm_util_double ${Boost_LIBRARIES} z) - +target_link_libraries(ada_opt_sm training_utils libcdec ksearch mteval utils klm klm_util klm_util_double ${Boost_LIBRARIES} z ${LIBDL_LIBRARIES}) diff --git a/training/utils/CMakeLists.txt b/training/utils/CMakeLists.txt index 1734ee73..2753b9f0 100644 --- a/training/utils/CMakeLists.txt +++ b/training/utils/CMakeLists.txt @@ -2,6 +2,8 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../utils) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../mteval) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../decoder) +find_package(Threads REQUIRED) + set(training_utils_STAT_SRCS candidate_set.h entropy.h @@ -21,11 +23,11 @@ add_library(training_utils STATIC ${training_utils_STAT_SRCS}) set(sentserver_SRCS sentserver.cc) add_executable(sentserver ${sentserver_SRCS}) -target_link_libraries(sentserver) +target_link_libraries(sentserver ${CMAKE_THREAD_LIBS_INIT}) set(sentclient_SRCS sentclient.cc) add_executable(sentclient ${sentclient_SRCS}) -target_link_libraries(sentclient) +target_link_libraries(sentclient ${CMAKE_THREAD_LIBS_INIT}) set(grammar_convert_SRCS grammar_convert.cc) add_executable(grammar_convert ${grammar_convert_SRCS}) diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt index 59fb644d..58668254 100644 --- a/utils/CMakeLists.txt +++ b/utils/CMakeLists.txt @@ -1,4 +1,4 @@ -include_directories() +set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(TEST_SRCS dict_test.cc logval_test.cc -- cgit v1.2.3 From 62b8b8e72c66da104e51d302ac41d1466b5d35ef Mon Sep 17 00:00:00 2001 From: Chris Dyer Date: Thu, 5 Mar 2015 15:15:28 -0500 Subject: fix extra logging --- training/mira/mira.py | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'training/mira') diff --git a/training/mira/mira.py b/training/mira/mira.py index ccecb10e..32478c4f 100755 --- a/training/mira/mira.py +++ b/training/mira/mira.py @@ -22,23 +22,9 @@ dlog = None #scoring function using pycdec scoring def fast_score(hyps, refs, metric): - #scorer = cdec.score.Scorer(metric) - #logging.info('loaded {0} references for scoring with {1}'.format( - # len(refs), metric)) - #if metric=='BLEU': - # logging.warning('BLEU is ambiguous, assuming IBM_BLEU\n') - # metric = 'IBM_BLEU' - #elif metric=='COMBI': - # logging.warning('COMBI metric is no longer supported, switching to ' - # 'COMB:TER=-0.5;BLEU=0.5') - # metric = 'COMB:TER=-0.5;BLEU=0.5' - #stats = sum(scorer(r).evaluate(h) for h,r in itertools.izip(hyps,refs)) - #logging.info('Score={} ({})'.format(stats.score, stats.detail)) - #return stats.score cmd = ('{0} -r{1} -i {2} -m {3}').format(fast_score_binary, refs, hyps, metric) proc = subprocess.Popen(shlex.split(cmd), stdout=subprocess.PIPE) o = proc.stdout.readline().strip() - print 'res: ', o return float(o) #create new parallel input file in output directory in sgml format -- cgit v1.2.3