Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lm
diff options
context:
space:
mode:
authorKenneth Heafield <github@kheafield.com>2016-01-13 02:39:27 +0300
committerKenneth Heafield <github@kheafield.com>2016-01-13 02:39:27 +0300
commit2a74f3a521e02c85638f6c26a06c4f6903f1e4ec (patch)
tree19b7e8a4eed8128017911a80028b2c2636b2bda3 /lm
parent3d051db850fbcc4da84da288afee2dd4056aec85 (diff)
KenLM e06ec4dc59f765482d7545b3cb797b8fc128ab9f
Diffstat (limited to 'lm')
-rw-r--r--lm/CMakeLists.txt89
-rw-r--r--lm/builder/CMakeLists.txt44
-rw-r--r--lm/builder/adjust_counts.cc2
3 files changed, 33 insertions, 102 deletions
diff --git a/lm/CMakeLists.txt b/lm/CMakeLists.txt
index 5fca22c71..e3ef06f04 100644
--- a/lm/CMakeLists.txt
+++ b/lm/CMakeLists.txt
@@ -13,7 +13,7 @@ cmake_minimum_required(VERSION 2.8.8)
# This CMake file was created by Lane Schwartz <dowobeha@gmail.com>
-set(KENLM_MAX_ORDER 6)
+set(KENLM_MAX_ORDER 6 CACHE STRING "Maximum supported ngram order")
add_definitions(-DKENLM_MAX_ORDER=${KENLM_MAX_ORDER})
@@ -64,76 +64,27 @@ set(EXE_LIST
build_binary
)
-# Iterate through the executable list
-foreach(exe ${EXE_LIST})
-
- # Compile the executable, linking against the requisite dependent object files
- add_executable(${exe} ${exe}_main.cc $<TARGET_OBJECTS:kenlm> $<TARGET_OBJECTS:kenlm_util>)
-
- # Link the executable against boost
- target_link_libraries(${exe} ${Boost_LIBRARIES} pthread)
-
- # Group executables together
- set_target_properties(${exe} PROPERTIES FOLDER executables)
-
-# End for loop
-endforeach(exe)
-
-
-# Install the executable files
-install(TARGETS ${EXE_LIST} DESTINATION bin)
-
+AddExes(EXES ${EXE_LIST}
+ DEPENDS $<TARGET_OBJECTS:kenlm> $<TARGET_OBJECTS:kenlm_util>
+ LIBRARIES ${Boost_LIBRARIES} pthread)
+# Conditionally build the interpolation code
+if(BUILD_INTERPOLATE)
+ add_subdirectory(interpolate)
+endif()
if(BUILD_TESTING)
- # Explicitly list the Boost test files to be compiled
- set(KENLM_BOOST_TESTS_LIST
- left_test
- model_test
- partial_test
- )
-
- # Iterate through the Boost tests list
- foreach(test ${KENLM_BOOST_TESTS_LIST})
-
- # Compile the executable, linking against the requisite dependent object files
- add_executable(${test} ${test}.cc $<TARGET_OBJECTS:kenlm> $<TARGET_OBJECTS:kenlm_util>)
-
- # Require the following compile flag
- set_target_properties(${test} PROPERTIES COMPILE_FLAGS -DBOOST_TEST_DYN_LINK)
-
- # Link the executable against boost
- target_link_libraries(${test} ${Boost_LIBRARIES} pthread)
-
- # model_test requires an extra command line parameter
- if ("${test}" STREQUAL "model_test")
- set(test_params
- ${CMAKE_CURRENT_SOURCE_DIR}/test.arpa
- ${CMAKE_CURRENT_SOURCE_DIR}/test_nounk.arpa
- )
- else()
- set(test_params
- ${CMAKE_CURRENT_SOURCE_DIR}/test.arpa
- )
- endif()
-
- # Specify command arguments for how to run each unit test
- #
- # Assuming that foo was defined via add_executable(foo ...),
- # the syntax $<TARGET_FILE:foo> gives the full path to the executable.
- #
- add_test(NAME ${test}_test
- COMMAND $<TARGET_FILE:${test}> ${test_params})
-
- # Group unit tests together
- set_target_properties(${test} PROPERTIES FOLDER "unit_tests")
-
- # End for loop
- endforeach(test)
-
+ set(KENLM_BOOST_TESTS_LIST left_test partial_test)
+ AddTests(TESTS ${KENLM_BOOST_TESTS_LIST}
+ DEPENDS $<TARGET_OBJECTS:kenlm> $<TARGET_OBJECTS:kenlm_util>
+ LIBRARIES ${Boost_LIBRARIES} pthread
+ TEST_ARGS ${CMAKE_CURRENT_SOURCE_DIR}/test.arpa)
+
+ # model_test requires an extra command line parameter
+ KenLMAddTest(TEST model_test
+ DEPENDS $<TARGET_OBJECTS:kenlm> $<TARGET_OBJECTS:kenlm_util>
+ LIBRARIES ${Boost_LIBRARIES} pthread
+ TEST_ARGS ${CMAKE_CURRENT_SOURCE_DIR}/test.arpa
+ ${CMAKE_CURRENT_SOURCE_DIR}/test_nounk.arpa)
endif()
-
-
-
-
diff --git a/lm/builder/CMakeLists.txt b/lm/builder/CMakeLists.txt
index 01b415da2..cc0d3ed9f 100644
--- a/lm/builder/CMakeLists.txt
+++ b/lm/builder/CMakeLists.txt
@@ -52,36 +52,16 @@ set_target_properties(lmplz PROPERTIES FOLDER executables)
if(BUILD_TESTING)
- # Explicitly list the Boost test files to be compiled
- set(KENLM_BOOST_TESTS_LIST
- adjust_counts_test
- corpus_count_test
- )
-
- # Iterate through the Boost tests list
- foreach(test ${KENLM_BOOST_TESTS_LIST})
-
- # Compile the executable, linking against the requisite dependent object files
- add_executable(${test} ${test}.cc $<TARGET_OBJECTS:kenlm> $<TARGET_OBJECTS:kenlm_common> $<TARGET_OBJECTS:kenlm_builder> $<TARGET_OBJECTS:kenlm_util>)
-
- # Require the following compile flag
- set_target_properties(${test} PROPERTIES COMPILE_FLAGS "-DBOOST_TEST_DYN_LINK -DBOOST_PROGRAM_OPTIONS_DYN_LINK")
-
- # Link the executable against boost
- target_link_libraries(${test} ${Boost_LIBRARIES} pthread)
-
- # Specify command arguments for how to run each unit test
- #
- # Assuming that foo was defined via add_executable(foo ...),
- # the syntax $<TARGET_FILE:foo> gives the full path to the executable.
- #
- add_test(NAME ${test}_test
- COMMAND $<TARGET_FILE:${test}>)
-
- # Group unit tests together
- set_target_properties(${test} PROPERTIES FOLDER "unit_tests")
-
- # End for loop
- endforeach(test)
-
+ # Explicitly list the Boost test files to be compiled
+ set(KENLM_BOOST_TESTS_LIST
+ adjust_counts_test
+ corpus_count_test
+ )
+
+ AddTests(TESTS ${KENLM_BOOST_TESTS_LIST}
+ DEPENDS $<TARGET_OBJECTS:kenlm>
+ $<TARGET_OBJECTS:kenlm_common>
+ $<TARGET_OBJECTS:kenlm_util>
+ $<TARGET_OBJECTS:kenlm_builder>
+ LIBRARIES ${Boost_LIBRARIES} pthread)
endif()
diff --git a/lm/builder/adjust_counts.cc b/lm/builder/adjust_counts.cc
index 3ac3e8d20..b4c5ba8b7 100644
--- a/lm/builder/adjust_counts.cc
+++ b/lm/builder/adjust_counts.cc
@@ -269,7 +269,7 @@ void AdjustCounts::Run(const util::stream::ChainPositions &positions) {
std::size_t same = full->end() - 1 - different;
// STEP 1: Output all the n-grams that changed.
- for (; lower_valid >= &streams[same]; --lower_valid) {
+ for (; lower_valid >= streams.begin() + same; --lower_valid) {
uint64_t order_minus_1 = lower_valid - streams_begin;
if(actual_counts[order_minus_1] <= prune_thresholds_[order_minus_1])
(*lower_valid)->Value().Mark();