Skip to content

Commit

Permalink
Merge branch 'master' of github.com:kpu/kenlm
Browse files Browse the repository at this point in the history
  • Loading branch information
kpu committed Aug 11, 2020
2 parents d8ded0f + 87e85e6 commit 0d29fe2
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 7 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,8 @@ include_directories(
add_subdirectory(util)
add_subdirectory(lm)

option (ENABLE_PYTHON "python bindings" OFF)
if(ENABLE_PYTHON)
add_subdirectory(python)
endif()

6 changes: 1 addition & 5 deletions cmake/KenLMFunctions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,8 @@ function(KenLMAddTest)
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 ${KenLMAddTest_TEST}
COMMAND $<TARGET_FILE:${KenLMAddTest_TEST}> ${test_params})
COMMAND ${KenLMAddTest_TEST} ${test_params})

# Group unit tests together
set_target_properties(${KenLMAddTest_TEST} PROPERTIES FOLDER "unit_tests")
Expand Down
1 change: 1 addition & 0 deletions lm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ if (NOT MSVC)
endif()

add_library(kenlm ${KENLM_LM_SOURCE} ${KENLM_LM_COMMON_SOURCE})
set_target_properties(kenlm PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_link_libraries(kenlm kenlm_util ${Boost_LIBRARIES} ${THREADS})

set(KENLM_MAX_ORDER 6 CACHE STRING "Maximum supported ngram order")
Expand Down
3 changes: 2 additions & 1 deletion lm/filter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ set(KENLM_FILTER_SOURCE
# refer to these objects as $<TARGET_OBJECTS:foo>
#
add_library(kenlm_filter ${KENLM_FILTER_SOURCE})
target_link_libraries(kenlm_filter kenlm_util)

if (NOT MSVC)
set(THREADS pthread)
endif()

AddExes(EXES filter phrase_table_vocab
LIBRARIES kenlm_filter kenlm kenlm_util ${Boost_LIBRARIES} ${THREADS})
LIBRARIES kenlm_filter kenlm)

3 changes: 2 additions & 1 deletion lm/interpolate/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ if(EIGEN3_FOUND)
endif()

add_library(kenlm_interpolate ${KENLM_INTERPOLATE_SOURCE})
target_link_libraries(kenlm_interpolate kenlm)

set(KENLM_INTERPOLATE_EXES
interpolate
Expand All @@ -36,7 +37,7 @@ if(EIGEN3_FOUND)
endif()

set(KENLM_INTERPOLATE_LIBS
kenlm_interpolate kenlm kenlm_util ${Boost_LIBRARIES} ${THREADS})
kenlm_interpolate)

AddExes(EXES ${KENLM_INTERPOLATE_EXES}
LIBRARIES ${KENLM_INTERPOLATE_LIBS})
Expand Down
28 changes: 28 additions & 0 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
find_package(PythonInterp REQUIRED)
find_package(PythonLibs ${PYTHON_VERSION_STRING} EXACT REQUIRED)
include_directories(${PYTHON_INCLUDE_DIRS})

add_library(kenlm_python MODULE kenlm.cpp score_sentence.cc)
set_target_properties(kenlm_python PROPERTIES OUTPUT_NAME kenlm)
set_target_properties(kenlm_python PROPERTIES PREFIX "")

if(APPLE)
set_target_properties(kenlm_python PROPERTIES SUFFIX ".so")
elseif(WIN32)
set_target_properties(kenlm_python PROPERTIES SUFFIX ".pyd")
endif()

target_link_libraries(kenlm_python kenlm)
if(WIN32)
target_link_libraries(kenlm_python ${PYTHON_LIBRARIES})
elseif(APPLE)
set_target_properties(kenlm_python PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
endif()

if (WIN32)
set (PYTHON_SITE_PACKAGES Lib/site-packages)
else ()
set (PYTHON_SITE_PACKAGES lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages)
endif ()

install(TARGETS kenlm_python DESTINATION ${PYTHON_SITE_PACKAGES})
1 change: 1 addition & 0 deletions util/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ endif()

# Group these objects together for later use.
add_library(kenlm_util ${KENLM_UTIL_DOUBLECONVERSION_SOURCE} ${KENLM_UTIL_STREAM_SOURCE} ${KENLM_UTIL_SOURCE})
set_target_properties(kenlm_util PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_link_libraries(kenlm_util ${Boost_LIBRARIES} ${READ_COMPRESSED_LIBS} ${THREADS} ${TIMER_LINK})

AddExes(EXES probing_hash_table_benchmark
Expand Down

0 comments on commit 0d29fe2

Please sign in to comment.