diff --git a/CMakeScripts/FindPwrUtils.cmake b/CMakeScripts/FindPwrUtils.cmake new file mode 100644 index 0000000000000000000000000000000000000000..62e25bb7e0789cabb5a1148fa85526e5a52757d4 --- /dev/null +++ b/CMakeScripts/FindPwrUtils.cmake @@ -0,0 +1,43 @@ +FIND_PATH(PwrUtils_INCLUDE_DIR foreach.h /usr/include/libpwrutils /usr/local/include/libpwrutils ) + +FIND_LIBRARY(PwrUtils_LIBRARY NAMES pwrutils PATH /usr/lib /usr/local/lib) + +MARK_AS_ADVANCED(PwrUtils_LIBRARY) +MARK_AS_ADVANCED(PwrUtils_INCLUDE_DIR) + + +IF (PwrUtils_INCLUDE_DIR AND PwrUtils_LIBRARY) + SET(PwrUtils_FOUND TRUE) +ENDIF (PwrUtils_INCLUDE_DIR AND PwrUtils_LIBRARY) + +IF (PwrUtils_FOUND) + set(PwrUtils_VERSION 0.0.0) + FIND_FILE(_PwrUtils_VERSION_FILE version.h ${PwrUtils_INCLUDE_DIR}) + MARK_AS_ADVANCED(_PwrUtils_VERSION_FILE) + IF (_PwrUtils_VERSION_FILE) + FILE(READ ${_PwrUtils_VERSION_FILE} _PwrUtils_VERSION_CONENTS) + STRING(REGEX REPLACE ".*#define LIBPWRUTILS_VERSION \\\"([0-9.]+)\\\".*" "\\1" PwrUtils_VERSION "${_PwrUtils_VERSION_CONENTS}") + ENDIF (_PwrUtils_VERSION_FILE) + IF (PwrUtils_FIND_VERSION) + IF (PwrUtils_VERSION VERSION_LESS PwrUtils_FIND_VERSION) + IF (PwrUtils_FIND_REQUIRED) + MESSAGE(${_PwrUtils_VERSION_FILE}) + MESSAGE(FATAL_ERROR "PwrUtils version too old: ${PwrUtils_VERSION}, requested >= ${PwrUtils_FIND_VERSION}") + ELSE (PwrUtils_FIND_REQUIRED) + IF (NOT PwrUtils_FIND_QUIETLY) + MESSAGE(STATUS "PwrUtils version too old: ${PwrUtils_VERSION}, requested >= ${PwrUtils_FIND_VERSION}") + ENDIF (NOT PwrUtils_FIND_QUIETLY) + ENDIF (PwrUtils_FIND_REQUIRED) + set(PwrUtils_FOUND False) + ENDIF (PwrUtils_VERSION VERSION_LESS PwrUtils_FIND_VERSION) + ENDIF (PwrUtils_FIND_VERSION) + IF (NOT PwrUtils_FIND_QUIETLY) + MESSAGE(STATUS "Found libpwrutils ${PwrUtils_VERSION}: ${PwrUtils_LIBRARY}") + ENDIF (NOT PwrUtils_FIND_QUIETLY) +ELSE (PwrUtils_FOUND) + IF (PwrUtils_FIND_REQUIRED) + MESSAGE(FATAL_ERROR "Could not find libpwrutils") + ELSE (PwrUtils_FIND_REQUIRED) + MESSAGE(STATUS "libpwrutils not found") + ENDIF (PwrUtils_FIND_REQUIRED) +ENDIF (PwrUtils_FOUND) diff --git a/libwccl/CMakeLists.txt b/libwccl/CMakeLists.txt index cdab23cc308c1ff0e0ff0235cd13571d23734fd1..c7044f66831026723fe989de3704a19fd553b433 100644 --- a/libwccl/CMakeLists.txt +++ b/libwccl/CMakeLists.txt @@ -4,9 +4,12 @@ PROJECT(wccl) include_directories( ${CMAKE_CURRENT_BINARY_DIR}/include/ ) -find_package(Corpus2 0.1.0 REQUIRED) +find_package(Corpus2 0.1.1 REQUIRED) set(LIBS ${LIBS} ${Corpus2_LIBRARY}) +find_package(PwrUtils 0.0.3 REQUIRED) +set(LIBS ${LIBS} ${PwrUtils_LIBRARY}) + link_directories(${Boost_LIBRARY_DIRS}) set(LIBS ${LIBS} ${Boost_LIBRARIES}) @@ -26,7 +29,7 @@ SET(libwccl_STAT_SRC file(GLOB_RECURSE INCS "*.h") add_library(wccl SHARED ${libwccl_STAT_SRC} ${INCS}) -target_link_libraries ( wccl ${LIBS} pwrutils) +target_link_libraries ( wccl ${LIBS} ) set_target_properties(wccl PROPERTIES VERSION "${ver_major}.${ver_minor}" diff --git a/libwccl/values/tset.cpp b/libwccl/values/tset.cpp index 41aec52051d8ec65c0643b3fde68974d08143dad..9573bcbb0b7ab0f4fcd645eb9d440c745413c2e4 100644 --- a/libwccl/values/tset.cpp +++ b/libwccl/values/tset.cpp @@ -1,7 +1,18 @@ #include <libwccl/values/tset.h> +#include <sstream> namespace Wccl { const char* TSet::type_name = "TSet"; +std::string TSet::to_raw_string() const +{ + return tag_.raw_dump(); +} + +std::string TSet::to_string(const Corpus2::Tagset& tagset) const +{ + return tagset.tag_to_symbol_string(tag_); +} + } /* end ns Wccl */ diff --git a/libwccl/values/tset.h b/libwccl/values/tset.h index 1618e0dc4e40491ef47da0bcea45e0a56ada56bc..5cd25a4b42d2490c1f62cba681cf84f952c065c0 100644 --- a/libwccl/values/tset.h +++ b/libwccl/values/tset.h @@ -33,6 +33,10 @@ public: return tag_; } + std::string to_string(const Corpus2::Tagset &) const; + + std::string to_raw_string() const; + private: Corpus2::Tag tag_; }; diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index c51017303f1f4bcc6300e5056393ab2f3735466f..2a538ca4e24e79fb799deb0d6702d6540b044e39 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -6,10 +6,11 @@ add_definitions(-DLIBWCCL_TEST_DATA_DIR="${PROJECT_SOURCE_DIR}/") add_executable(tests constant_tests.cpp + context.cpp main.cpp - variables.cpp position.cpp - context.cpp + values.cpp + variables.cpp ) target_link_libraries ( tests wccl ${Boost_LIBRARIES}) diff --git a/tests/values.cpp b/tests/values.cpp new file mode 100644 index 0000000000000000000000000000000000000000..6d2ac2d2f786ebc437028bbdf2c375dd096946e8 --- /dev/null +++ b/tests/values.cpp @@ -0,0 +1,28 @@ +#include <boost/test/unit_test.hpp> +#include <boost/bind.hpp> + +#include <libwccl/variables.h> + +#include <iostream> + +using namespace Wccl; + +BOOST_AUTO_TEST_SUITE(values) + +BOOST_AUTO_TEST_CASE(boolz) +{ + Bool b; + BOOST_CHECK_EQUAL(b.get_value(), false); + Value& v = b; + BOOST_CHECK_EQUAL(v.get_type_name(), Bool::type_name); +} + +BOOST_AUTO_TEST_CASE(tsetz) +{ + TSet t; + BOOST_CHECK(t.get_tag().is_null()); + Value& v = t; + BOOST_CHECK_EQUAL(v.get_type_name(), TSet::type_name); +} + +BOOST_AUTO_TEST_SUITE_END()