From 3c208270b96a28d4f74d2504a056b8caeedfc7b3 Mon Sep 17 00:00:00 2001 From: rafalj Date: Thu, 24 Oct 2013 17:08:58 +0200 Subject: [PATCH] init --- .gitignore | 5 + concordia-console/CMakeLists.txt | 21 +++ concordia-console/concordia-console.cpp | 60 +++++++ concordia/CMakeLists.txt | 35 ++++ concordia/common/CMakeLists.txt | 0 concordia/common/config.hpp.in | 14 ++ concordia/common/logging.cpp | 128 ++++++++++++++ concordia/common/logging.hpp | 166 ++++++++++++++++++ concordia/compilation.dox | 61 +++++++ concordia/concordia.cpp | 37 ++++ concordia/concordia.hpp | 38 ++++ concordia/concordia_config.cpp | 32 ++++ concordia/concordia_config.hpp | 46 +++++ concordia/concordia_exception.cpp | 19 ++ concordia/concordia_exception.hpp | 36 ++++ concordia/main.dox | 12 ++ concordia/running.dox | 32 ++++ concordia/t/CMakeLists.txt | 6 + concordia/t/test_concordia.cpp | 19 ++ concordia/t/test_concordia_config.cpp | 52 ++++++ concordia/technical.dox | 28 +++ .../concordia-config/concordia.cfg.in | 11 ++ prod/resources/puddle/tagset.txt | 7 + 23 files changed, 865 insertions(+) create mode 100644 .gitignore create mode 100644 concordia-console/CMakeLists.txt create mode 100644 concordia-console/concordia-console.cpp create mode 100644 concordia/CMakeLists.txt create mode 100644 concordia/common/CMakeLists.txt create mode 100644 concordia/common/config.hpp.in create mode 100644 concordia/common/logging.cpp create mode 100644 concordia/common/logging.hpp create mode 100644 concordia/compilation.dox create mode 100644 concordia/concordia.cpp create mode 100644 concordia/concordia.hpp create mode 100644 concordia/concordia_config.cpp create mode 100644 concordia/concordia_config.hpp create mode 100644 concordia/concordia_exception.cpp create mode 100644 concordia/concordia_exception.hpp create mode 100644 concordia/main.dox create mode 100644 concordia/running.dox create mode 100644 concordia/t/CMakeLists.txt create mode 100644 concordia/t/test_concordia.cpp create mode 100644 concordia/t/test_concordia_config.cpp create mode 100644 concordia/technical.dox create mode 100644 prod/resources/concordia-config/concordia.cfg.in create mode 100644 prod/resources/puddle/tagset.txt diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cba68e1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +build +cppcheck-result.txt +cpplint-result.txt +prod/resources/concordia-config/concordia.cfg + diff --git a/concordia-console/CMakeLists.txt b/concordia-console/CMakeLists.txt new file mode 100644 index 0000000..424022e --- /dev/null +++ b/concordia-console/CMakeLists.txt @@ -0,0 +1,21 @@ + +add_executable(concordia-console concordia-console.cpp) + +target_link_libraries(concordia-console concordia ${Boost_LIBRARIES} ${LIBCONFIG_LIB} ${LIBSTEMMER_LIB}) + +if (WITH_RE2) + target_link_libraries(concordia-console re2) + if (WITH_PCRE) + target_link_libraries(concordia-console pcrecpp) + endif(WITH_PCRE) +else(WITH_RE2) + if (WITH_PCRE) + target_link_libraries(concordia-console pcrecpp) + endif(WITH_PCRE) +endif(WITH_RE2) + +# ===================================== + +install(TARGETS concordia-console DESTINATION bin/) + + diff --git a/concordia-console/concordia-console.cpp b/concordia-console/concordia-console.cpp new file mode 100644 index 0000000..f613200 --- /dev/null +++ b/concordia-console/concordia-console.cpp @@ -0,0 +1,60 @@ +#include +#include +#include +#include + +#include "concordia/concordia.hpp" + +namespace po = boost::program_options; + +int main(int argc, char** argv) { + po::options_description desc("Allowed options"); + + desc.add_options() + ("help,h", "Display this message") + ("config,c", boost::program_options::value(), + "Concordia configuration file (required)"); + + po::variables_map cli; + po::store(po::parse_command_line(argc, argv, desc), cli); + po::notify(cli); + + if (cli.count("help")) { + std::cerr << desc << std::endl; + return 1; + } + + std::string configFile; + if (cli.count("config")) { + configFile = cli["config"].as(); + } else { + std::cerr << "No Concordia configuration file given. Terminating." + << std::endl; + return 1; + } + + + try { + Concordia concordia(configFile); + std::cout << "Welcome to Concordia. Version = " + << concordia.getVersion() << endl; + } catch(ConcordiaException & e) { + std::cerr << "ConcordiaException caught with message: " + << std::endl + << e.what() + << std::endl + << "Terminating execution." + << std::endl; + return 1; + } catch(exception & e) { + std::cerr << "Exception caught with message: " + << std::endl + << e.what() + << std::endl + << "Terminating execution." + << std::endl; + return 1; + } + + return 0; +} diff --git a/concordia/CMakeLists.txt b/concordia/CMakeLists.txt new file mode 100644 index 0000000..f54eab8 --- /dev/null +++ b/concordia/CMakeLists.txt @@ -0,0 +1,35 @@ +set(ALL_DIRECTORIES common) + +foreach(dir ${ALL_DIRECTORIES}) + link_directories("${concordia_BINARY_DIR}/${dir}") + add_subdirectory(${dir}) +endforeach(dir) + +add_library(concordia SHARED + concordia.cpp + concordia_config.cpp + concordia_exception.cpp + common/logging.cpp + ) + +add_subdirectory(t) +# ===================================== + +install(TARGETS concordia DESTINATION lib/) +install(FILES concordia.hpp DESTINATION include/concordia/) + +target_link_libraries(concordia log4cpp) +target_link_libraries(concordia ${LIBSTEMMER_LIB}) +target_link_libraries(concordia ${Boost_LIBRARIES}) + +if (WITH_RE2) + target_link_libraries(concordia re2) + if (WITH_PCRE) + target_link_libraries(concordia pcrecpp) + endif(WITH_PCRE) +else(WITH_RE2) + if (WITH_PCRE) + target_link_libraries(concordia pcrecpp) + endif(WITH_PCRE) +endif(WITH_RE2) + diff --git a/concordia/common/CMakeLists.txt b/concordia/common/CMakeLists.txt new file mode 100644 index 0000000..e69de29 diff --git a/concordia/common/config.hpp.in b/concordia/common/config.hpp.in new file mode 100644 index 0000000..16fbda7 --- /dev/null +++ b/concordia/common/config.hpp.in @@ -0,0 +1,14 @@ +#define CONCORDIA_VERSION_MAJOR @CONCORDIA_VERSION_MAJOR@ +#define CONCORDIA_VERSION_MINOR @CONCORDIA_VERSION_MINOR@ + +#define TEST_RESOURCES_DIRECTORY "@TEST_RESOURCES_DIRECTORY@" + +#define PROD_RESOURCES_DIRECTORY "@PROD_RESOURCES_DIRECTORY@" + +#define LEMMA_CATEGORY_SEPARATOR '+' + +#cmakedefine01 HAVE_RE2 +#cmakedefine01 HAVE_PCRE + +#define LEXICON_TEXT_FIELD_SEPARATORS "\t " +#define LEXICON_FIELD_SEPARATOR "\t" diff --git a/concordia/common/logging.cpp b/concordia/common/logging.cpp new file mode 100644 index 0000000..f541d41 --- /dev/null +++ b/concordia/common/logging.cpp @@ -0,0 +1,128 @@ +#include "concordia/common/logging.hpp" + +#include +#include + +ConcordiaLogger concordia_logger; + +ConcordiaLogger::ConcordiaLogger() : + logger_category( + log4cpp::Category::getInstance("Category")) { + initialize_logger_(); +} + +void ConcordiaLogger::initialize_logger_() { + setDefaultLoggerAppender_(); + logger_category.setPriority(log4cpp::Priority::WARN); +} + +void ConcordiaLogger::setDefaultLoggerAppender_() { + log4cpp::Appender * default_logger_appender = + new log4cpp::OstreamAppender( + "OstreamAppender", &std::cerr); + + addDefaultLayoutToAppender_(default_logger_appender); + + setNewLoggerAppender_(default_logger_appender); +} + +void ConcordiaLogger::addDefaultLayoutToAppender_( + log4cpp::Appender * appender) { + log4cpp::PatternLayout * layout = + new log4cpp::PatternLayout(); + + layout->setConversionPattern("%p %d{%Y-%m-%d %H:%M:%S,%l} : %m%n"); + + appender->setLayout(layout); +} + +ConcordiaLogger::~ConcordiaLogger() { +} + +void ConcordiaLogger::setLoggingToFile(const std::string & filepath) { + log4cpp::Appender * appender = + new log4cpp::FileAppender("FileAppender", filepath.c_str()); + + setNewLoggerAppender_(appender); +} + +void ConcordiaLogger::setLoggingPriority(const std::string & priorityName) { + try { + log4cpp::Priority::Value newPriority = + log4cpp::Priority::getPriorityValue(priorityName); + logger_category.setPriority(newPriority); + } catch(std::invalid_argument &) { + ERROR("Unknown priority name: " << priorityName); + } +} + +log4cpp::Priority::Value ConcordiaLogger::getLoggingPriority() { + return logger_category.getPriority(); +} + +void ConcordiaLogger::setNewLoggerAppender_(log4cpp::Appender * appender) { + logger_category.removeAllAppenders(); + + current_logger_appender = appender; + logger_category.setAppender(current_logger_appender); +} + +void ConcordiaLogger::flush(log4cpp::Priority::Value priorityLevel) { + logger_category.log(priorityLevel, buffer.str()); + buffer.str(""); +} + +ConcordiaLogger & ConcordiaLogger::operator<< (const std::string & msg) { + buffer << msg; + return *this; +} + +ConcordiaLogger & ConcordiaLogger::operator<< (const char * msg) { + buffer << msg; + return *this; +} + +ConcordiaLogger & ConcordiaLogger::operator<< (unsigned long msg) { + buffer << msg; + return *this; +} + +ConcordiaLogger & ConcordiaLogger::operator<< (signed long msg) { + buffer << msg; + return *this; +} + +ConcordiaLogger & ConcordiaLogger::operator<< (unsigned int msg) { + buffer << msg; + return *this; +} + +ConcordiaLogger & ConcordiaLogger::operator<< (signed int msg) { + buffer << msg; + return *this; +} + +ConcordiaLogger & ConcordiaLogger::operator<< (unsigned short msg) { + buffer << msg; + return *this; +} + +ConcordiaLogger & ConcordiaLogger::operator<< (signed short msg) { + buffer << msg; + return *this; +} + +ConcordiaLogger & ConcordiaLogger::operator<< (float msg) { + buffer << msg; + return *this; +} + +ConcordiaLogger & ConcordiaLogger::operator<< (double msg) { + buffer << msg; + return *this; +} + +ConcordiaLogger & ConcordiaLogger::operator<< (bool msg) { + buffer << msg; + return *this; +} diff --git a/concordia/common/logging.hpp b/concordia/common/logging.hpp new file mode 100644 index 0000000..3d54f0d --- /dev/null +++ b/concordia/common/logging.hpp @@ -0,0 +1,166 @@ +#ifndef LOGGING_HDR +#define LOGGING_HDR + +#include +#include +#include +#include + +#include +#include + +#include "concordia/common/config.hpp" + +/*! Logging class based on the log4cpp library. The class comes from PSI-Toolkit. +*/ + +class ConcordiaLogger { +public: + /*! Default constructor. + */ + ConcordiaLogger(); + + /*! Destructor. + */ + ~ConcordiaLogger(); + + /*! A method to initialize the log file. + \param filepath the path of the log file + */ + void setLoggingToFile(const std::string & filepath); + + /*! Setter for the logging priority. + \param priorityName the log4cpp name of the logging priority + */ + void setLoggingPriority(const std::string & priorityName); + + /*! Getter for the logging priority + \returns the current logging priority. + */ + log4cpp::Priority::Value getLoggingPriority(); + + /*! Flush the current string buffer for given priorityLevel. + \param priorityLevel the logging priority of the buffer to flush + */ + void flush(log4cpp::Priority::Value priorityLevel); + + /*! Operator for direct logging. + \param msg message to log + */ + ConcordiaLogger & operator<< (const std::string & msg); + + /*! Operator for direct logging. + \param msg message to log + */ + ConcordiaLogger & operator<< (const char * msg); + + /*! Operator for direct logging. + \param msg message to log + */ + ConcordiaLogger & operator<< (unsigned long msg); + + /*! Operator for direct logging. + \param msg message to log + */ + ConcordiaLogger & operator<< (signed long msg); + + /*! Operator for direct logging. + \param msg message to log + */ + ConcordiaLogger & operator<< (unsigned int msg); + + /*! Operator for direct logging. + \param msg message to log + */ + ConcordiaLogger & operator<< (signed int msg); + + /*! Operator for direct logging. + \param msg message to log + */ + ConcordiaLogger & operator<< (unsigned short msg); + + /*! Operator for direct logging. + \param msg message to log + */ + ConcordiaLogger & operator<< (signed short msg); + + /*! Operator for direct logging. + \param msg message to log + */ + ConcordiaLogger & operator<< (float msg); + + /*! Operator for direct logging. + \param msg message to log + */ + ConcordiaLogger & operator<< (double msg); + + /*! Operator for direct logging. + \param msg message to log + */ + ConcordiaLogger & operator<< (bool msg); + +private: + void initialize_logger_(); + void setDefaultLoggerAppender_(); + void addDefaultLayoutToAppender_(log4cpp::Appender * appender); + void setNewLoggerAppender_(log4cpp::Appender * appender); + + std::stringstream buffer; + log4cpp::Category & logger_category; + log4cpp::Appender * current_logger_appender; +}; + +extern ConcordiaLogger concordia_logger; + +#define TRACE(M) \ + do { \ + concordia_logger << M; \ + concordia_logger.flush(log4cpp::Priority::DEBUG); \ + } while (0) + +#define DEBUG(M) \ + do { \ + concordia_logger << M; \ + concordia_logger.flush(log4cpp::Priority::DEBUG); \ + } while (0) + +#define DEBUG_NOFLUSH(M) \ + do { \ + concordia_logger << M; \ + } while (0) + +#define FLUSH \ + do { \ + concordia_logger.flush(log4cpp::Priority::DEBUG); \ + } while (0) + +#define INFO(M) \ + do { \ + concordia_logger << M; \ + concordia_logger.flush(log4cpp::Priority::INFO); \ + } while (0) + +#define WARN(M) \ + do { \ + concordia_logger << M; \ + concordia_logger.flush(log4cpp::Priority::WARN); \ + } while (0) + +#define ERROR(M) \ + do { \ + concordia_logger << M; \ + concordia_logger.flush(log4cpp::Priority::ERROR); \ + } while (0) + +#define FATAL(M) \ + do { \ + concordia_logger << M; \ + concordia_logger.flush(log4cpp::Priority::FATAL); \ + } while (0) + + +#define SET_LOGGER_FILE(M) do { concordia_logger.setLoggingToFile(M); \ + } while (0); +#define SET_LOGGING_LEVEL(M) \ + do { concordia_logger.setLoggingPriority(M); } while (0); +#endif diff --git a/concordia/compilation.dox b/concordia/compilation.dox new file mode 100644 index 0000000..b759082 --- /dev/null +++ b/concordia/compilation.dox @@ -0,0 +1,61 @@ +/** \page compilation Concordia Installation & Build Manual + +This file describes how to compile, build +and install Concordia library. + +\section compilation1 Requirements + +- cmake +- Boost library +- Log4cpp +- libstemmer (Snowball stemming library) +- (optional) Doxygen + +\subsection compilation1_1 Boost Ubuntu installation + +sudo apt-get install libboost-dev libboost-serialization-dev libboost-test-dev libboost-filesystem-dev libboost-system-de libboost-program-options-dev libboost-iostreams-dev + +\subsection compilation1_2 Log4cpp Ubuntu installation + +sudo apt-get install liblog4cpp5-dev + +\subsection compilation1_3 Libconfig Ubuntu installation + +sudo apt-get install libconfig++-dev +sudo apt-get install libconfig-dev + +\subsection compilation1_4 Libstemmer Ubuntu installation + +sudo apt-get install libstemmer-dev + +\subsection compilation1_5 Perl-compatible regular expressions (PCRE) Ubuntu installation + +sudo apt-get install libpcre3-dev + +\subsection compilation1_6 Doxygen Ubuntu installation + +sudo apt-get install doxygen + +\section compilation2 Build & installation procedure + +mkdir build
+cd build
+../cmake.sh
+make
+make test
+make install + +\section compilation3 Documentation + +If Doxygen is available, a successful compilation generates documentation data in three +formats in the build/doc directory. + +The man files in doc/man will be installed during installation. Open doc/html/index.html for +a HTML version of the same documentation. The latex directory contains uncompiled latex +files. To generate a single pdf file run + +cd doc/latex +make + +This should generate a single file called refman.pdf in the same directory. +*/ diff --git a/concordia/concordia.cpp b/concordia/concordia.cpp new file mode 100644 index 0000000..181d5a0 --- /dev/null +++ b/concordia/concordia.cpp @@ -0,0 +1,37 @@ +#include "concordia/concordia.hpp" +#include "concordia/common/config.hpp" + +#include + +// =========================================== + +std::string _createLibraryVersion(); + +// =========================================== + +std::string Concordia::_libraryVersion = _createLibraryVersion(); + +// =========================================== + +Concordia::Concordia(const string & configFilePath) throw(ConcordiaException) { + boost::shared_ptr _config( + new ConcordiaConfig(configFilePath)); +} + +Concordia::~Concordia() { +} + +std::string & Concordia::getVersion() { + return _libraryVersion; +} + +std::string _createLibraryVersion() { + std::stringstream version; + + version << CONCORDIA_VERSION_MAJOR + << "." + << CONCORDIA_VERSION_MINOR; + + return version.str(); +} + diff --git a/concordia/concordia.hpp b/concordia/concordia.hpp new file mode 100644 index 0000000..36e8780 --- /dev/null +++ b/concordia/concordia.hpp @@ -0,0 +1,38 @@ +#ifndef CONCORDIA_HDR +#define CONCORDIA_HDR + +#include +#include + +#include "concordia/concordia_config.hpp" + +/*! + The Concordia class is the main access point to the library. + +*/ + +class Concordia { +public: + /*! Constructor. + \param configFilePath path to the Concordia configuration file + \throws ConcordiaException + */ + explicit Concordia(const std::string & configFilePath) + throw(ConcordiaException); + /*! Destructor. + */ + virtual ~Concordia(); + + /*! Getter for version. + \returns version of the Concordia library. + */ + std::string & getVersion(); + + +private: + static std::string _libraryVersion; + + boost::shared_ptr _config; +}; + +#endif diff --git a/concordia/concordia_config.cpp b/concordia/concordia_config.cpp new file mode 100644 index 0000000..8126be8 --- /dev/null +++ b/concordia/concordia_config.cpp @@ -0,0 +1,32 @@ +#include +#include "concordia/concordia_config.hpp" +#include "concordia/common/logging.hpp" + +#define PUDDLE_TAGSET_PARAM "puddle_tagset_path" + +ConcordiaConfig::ConcordiaConfig(const string & configFilePath) + throw(ConcordiaException) { + try { + _config.readFile(configFilePath.c_str()); + } catch(ParseException & e) { + throw ConcordiaException("Error parsing config file: "+configFilePath); + } catch(FileIOException & e) { + throw ConcordiaException("I/O error reading config file: " + +configFilePath); + } + + _puddleTagsetFilePath = + ConcordiaConfig::_readConfigParameterStr(PUDDLE_TAGSET_PARAM); +} + +ConcordiaConfig::~ConcordiaConfig() { +} + +string ConcordiaConfig::_readConfigParameterStr(const string & name) + throw(ConcordiaException) { + if (!_config.exists(name)) { + throw ConcordiaException("Config error: "+name+" setting not found"); + } else { + return _config.lookup(name); + } +} diff --git a/concordia/concordia_config.hpp b/concordia/concordia_config.hpp new file mode 100644 index 0000000..557b0e6 --- /dev/null +++ b/concordia/concordia_config.hpp @@ -0,0 +1,46 @@ +#ifndef CONCORDIA_CONFIG_HDR +#define CONCORDIA_CONFIG_HDR + +#include +#include +#include + +#include "concordia/concordia_exception.hpp" + +using namespace std; +using namespace libconfig; + +/*! +Class representing the Concordia configuration. +*/ +class ConcordiaConfig { +public: + /*! + Constructor. + \param configFilePath path of the configuration file (see \ref running3 for file specification). + \throws ConcordiaException + */ + explicit ConcordiaConfig(const string & configFilePath) + throw(ConcordiaException); + + /*! Destructor. + */ + virtual ~ConcordiaConfig(); + + /*! Getter for the puddle file path parameter. + \returns file path of the puddle tagset + */ + string & getPuddleTagsetFilePath() { + return _puddleTagsetFilePath; + } + +private: + Config _config; + + string _puddleTagsetFilePath; + + string _readConfigParameterStr(const string & name) + throw(ConcordiaException); +}; + +#endif diff --git a/concordia/concordia_exception.cpp b/concordia/concordia_exception.cpp new file mode 100644 index 0000000..45c8610 --- /dev/null +++ b/concordia/concordia_exception.cpp @@ -0,0 +1,19 @@ +#include "concordia_exception.hpp" + +ConcordiaException::ConcordiaException() throw(): + _message("Concordia exception") { +} + +ConcordiaException::ConcordiaException(const string & message) throw(): + _message(message) { +} + +ConcordiaException::~ConcordiaException() throw() { +} + +const char* ConcordiaException::what() const throw() { + char * m = new char[_message.size() + 1]; + m[_message.size()]=0; + memcpy(m, _message.c_str(), _message.size()); + return m; +} diff --git a/concordia/concordia_exception.hpp b/concordia/concordia_exception.hpp new file mode 100644 index 0000000..dcffb3a --- /dev/null +++ b/concordia/concordia_exception.hpp @@ -0,0 +1,36 @@ +#ifndef CONCORDIA_EXCEPTION_HDR +#define CONCORDIA_EXCEPTION_HDR + +#include +#include +#include + +using namespace std; + +/*! +Class representing an internal exception thrown in the Concordia library. +*/ +class ConcordiaException : public exception { +public: + /*! Constructor. + */ + ConcordiaException() throw(); + + /*! Constructor with a message. + \param message message of the exception + */ + explicit ConcordiaException(const string & message) throw(); + + /*! Destructor. + */ + ~ConcordiaException() throw(); + + /*! Implementation of the virtual method which provides the exception message. + */ + virtual const char* what() const throw(); + +private: + string _message; +}; + +#endif diff --git a/concordia/main.dox b/concordia/main.dox new file mode 100644 index 0000000..0ecfb71 --- /dev/null +++ b/concordia/main.dox @@ -0,0 +1,12 @@ +/** \mainpage Introduction + +\section main_1 Concordia - Tool for concordance search in CAT + + +\section main_2 Overview + +- \subpage compilation This chapter contains instructions to compile, install and run Concordia. +- \subpage running The methods of making use of the Concordia library are described in this chapter. +- \subpage technical In this chapter technical information about unit tests, project resources and code style is provided. + +*/ diff --git a/concordia/running.dox b/concordia/running.dox new file mode 100644 index 0000000..83f9aa2 --- /dev/null +++ b/concordia/running.dox @@ -0,0 +1,32 @@ +/** \page running Running the Concordia library + +\section running1 Programmatical use of the library + +The main access point to the functionalities of the library is the Concordia class. An example programmatical use of the class is shown below: + +\verbatim +snippet +\endverbatim + +\section running2 The concordia-console program + + +After successful build of the project (see \ref compilation2) the concordia-console program is available in the folder build/concordia-console. + +\subsection running2_1 concordia-console options + +The full list of program options is given below: + +\verbatim + -h [ --help ] Display this message + -c [ --config ] arg Concordia configuration file (required) +\endverbatim + +\subsection running2_2 concordia-console example run + +\subsection running2_3 concordia-console output format + + +\section running3 The Concordia configuration + +Concordia is configured by the means of a configuration file in the libconfig format (http://www.hyperrealm.com/libconfig/). diff --git a/concordia/t/CMakeLists.txt b/concordia/t/CMakeLists.txt new file mode 100644 index 0000000..3dc5c4e --- /dev/null +++ b/concordia/t/CMakeLists.txt @@ -0,0 +1,6 @@ +add_library(concordia-tests + test_concordia.cpp + test_concordia_config.cpp + ) + +target_link_libraries(concordia-tests concordia ${LIBCONFIG_LIB} concordia-tests-common) diff --git a/concordia/t/test_concordia.cpp b/concordia/t/test_concordia.cpp new file mode 100644 index 0000000..9248238 --- /dev/null +++ b/concordia/t/test_concordia.cpp @@ -0,0 +1,19 @@ +#include "tests/unit-tests/unit_tests_globals.hpp" +#include "concordia/concordia.hpp" +#include "tests/common/test_resources_manager.hpp" + + +#include + +using namespace std; + +BOOST_AUTO_TEST_SUITE(concordia_main) + +BOOST_AUTO_TEST_CASE( ConcordiaVersion ) +{ + Concordia concordia = Concordia(TestResourcesManager::getTestConcordiaConfigFilePath("concordia.cfg")); + string version = concordia.getVersion(); + BOOST_CHECK_EQUAL( version , "0.1"); +} + +BOOST_AUTO_TEST_SUITE_END() diff --git a/concordia/t/test_concordia_config.cpp b/concordia/t/test_concordia_config.cpp new file mode 100644 index 0000000..9e6566b --- /dev/null +++ b/concordia/t/test_concordia_config.cpp @@ -0,0 +1,52 @@ +#include "tests/unit-tests/unit_tests_globals.hpp" + +#include "concordia/concordia_config.hpp" +#include "tests/common/test_resources_manager.hpp" + +#include +#include +#include + +using namespace std; + +BOOST_AUTO_TEST_SUITE(concordia_config) + +BOOST_AUTO_TEST_CASE( ConfigParameters ) +{ + ConcordiaConfig config(TestResourcesManager::getTestConcordiaConfigFilePath("concordia-test.cfg")); + BOOST_CHECK_EQUAL( config.getPuddleTagsetFilePath() , "puddle/tagset.txt" ); +} + +BOOST_AUTO_TEST_CASE( NonexistentConfigTest ) +{ + bool exceptionThrown = false; + string message = ""; + try { + ConcordiaConfig config(TestResourcesManager::getTestConcordiaConfigFilePath("foo.cfg")); + } catch (ConcordiaException & e) { + exceptionThrown = true; + message = e.what(); + } + BOOST_CHECK_EQUAL(exceptionThrown, true); + BOOST_CHECK_EQUAL(boost::starts_with(message, "I/O error reading config file"), true); +} + + +BOOST_AUTO_TEST_CASE( InvalidConfigTest ) +{ + bool exceptionThrown = false; + string message = ""; + try { + ConcordiaConfig config(TestResourcesManager::getTestConcordiaConfigFilePath("invalid.cfg")); + } catch (ConcordiaException & e) { + exceptionThrown = true; + message = e.what(); + } + BOOST_CHECK_EQUAL(exceptionThrown, true); + BOOST_CHECK_EQUAL(boost::starts_with(message, "Error parsing config file"), true); +} + + + + +BOOST_AUTO_TEST_SUITE_END() diff --git a/concordia/technical.dox b/concordia/technical.dox new file mode 100644 index 0000000..d64b24e --- /dev/null +++ b/concordia/technical.dox @@ -0,0 +1,28 @@ +/** \page technical Project technical information + +\section technical1 Development + +\subsection technical1_1 Code style + +Use: ./run-checkers.sh script to find the most +C++ coding errors. The script uses the following +external tools: + +- cpplint.py (http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml?showone=cpplint) +- cppcheck + +The reports are stored in the XXX-result.txt files (where XXX is the name of the tool) +in the current directory. + +\subsection technical1_2 Unit tests + +Unit tests are integrated into makefiles. Unit tests codes are +put in the t/ subdirectory for each library. + +In order to run all unit tests just type: + +make test + +You can get detailed test report by running: + +./tests/unit-tests/test_runner diff --git a/prod/resources/concordia-config/concordia.cfg.in b/prod/resources/concordia-config/concordia.cfg.in new file mode 100644 index 0000000..3e10de1 --- /dev/null +++ b/prod/resources/concordia-config/concordia.cfg.in @@ -0,0 +1,11 @@ +#---------------------------- +# Concordia configuration file +#--------------------------- +# + +#Path to the Puddle tagset +puddle_tagset_path = "@PROD_PUDDLE_TAGSET_PATH@"; + + + +### eof diff --git a/prod/resources/puddle/tagset.txt b/prod/resources/puddle/tagset.txt new file mode 100644 index 0000000..bf8892f --- /dev/null +++ b/prod/resources/puddle/tagset.txt @@ -0,0 +1,7 @@ +[ATTR] + +case = nom gen dat acc inst loc voc + +[POS] + +subst = case