init
This commit is contained in:
parent
12ac566533
commit
3c208270b9
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
build
|
||||
cppcheck-result.txt
|
||||
cpplint-result.txt
|
||||
prod/resources/concordia-config/concordia.cfg
|
||||
|
21
concordia-console/CMakeLists.txt
Normal file
21
concordia-console/CMakeLists.txt
Normal file
@ -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/)
|
||||
|
||||
|
60
concordia-console/concordia-console.cpp
Normal file
60
concordia-console/concordia-console.cpp
Normal file
@ -0,0 +1,60 @@
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <boost/program_options.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
#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<std::string>(),
|
||||
"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<std::string>();
|
||||
} 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;
|
||||
}
|
35
concordia/CMakeLists.txt
Normal file
35
concordia/CMakeLists.txt
Normal file
@ -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)
|
||||
|
0
concordia/common/CMakeLists.txt
Normal file
0
concordia/common/CMakeLists.txt
Normal file
14
concordia/common/config.hpp.in
Normal file
14
concordia/common/config.hpp.in
Normal file
@ -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"
|
128
concordia/common/logging.cpp
Normal file
128
concordia/common/logging.cpp
Normal file
@ -0,0 +1,128 @@
|
||||
#include "concordia/common/logging.hpp"
|
||||
|
||||
#include <log4cpp/FileAppender.hh>
|
||||
#include <log4cpp/PatternLayout.hh>
|
||||
|
||||
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;
|
||||
}
|
166
concordia/common/logging.hpp
Normal file
166
concordia/common/logging.hpp
Normal file
@ -0,0 +1,166 @@
|
||||
#ifndef LOGGING_HDR
|
||||
#define LOGGING_HDR
|
||||
|
||||
#include <log4cpp/Category.hh>
|
||||
#include <log4cpp/OstreamAppender.hh>
|
||||
#include <log4cpp/SimpleLayout.hh>
|
||||
#include <log4cpp/Priority.hh>
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
#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
|
61
concordia/compilation.dox
Normal file
61
concordia/compilation.dox
Normal file
@ -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<br/>
|
||||
cd build<br/>
|
||||
../cmake.sh<br/>
|
||||
make<br/>
|
||||
make test<br/>
|
||||
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.
|
||||
*/
|
37
concordia/concordia.cpp
Normal file
37
concordia/concordia.cpp
Normal file
@ -0,0 +1,37 @@
|
||||
#include "concordia/concordia.hpp"
|
||||
#include "concordia/common/config.hpp"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
// ===========================================
|
||||
|
||||
std::string _createLibraryVersion();
|
||||
|
||||
// ===========================================
|
||||
|
||||
std::string Concordia::_libraryVersion = _createLibraryVersion();
|
||||
|
||||
// ===========================================
|
||||
|
||||
Concordia::Concordia(const string & configFilePath) throw(ConcordiaException) {
|
||||
boost::shared_ptr<ConcordiaConfig> _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();
|
||||
}
|
||||
|
38
concordia/concordia.hpp
Normal file
38
concordia/concordia.hpp
Normal file
@ -0,0 +1,38 @@
|
||||
#ifndef CONCORDIA_HDR
|
||||
#define CONCORDIA_HDR
|
||||
|
||||
#include <string>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
#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<ConcordiaConfig> _config;
|
||||
};
|
||||
|
||||
#endif
|
32
concordia/concordia_config.cpp
Normal file
32
concordia/concordia_config.cpp
Normal file
@ -0,0 +1,32 @@
|
||||
#include <sstream>
|
||||
#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);
|
||||
}
|
||||
}
|
46
concordia/concordia_config.hpp
Normal file
46
concordia/concordia_config.hpp
Normal file
@ -0,0 +1,46 @@
|
||||
#ifndef CONCORDIA_CONFIG_HDR
|
||||
#define CONCORDIA_CONFIG_HDR
|
||||
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <libconfig.h++>
|
||||
|
||||
#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
|
19
concordia/concordia_exception.cpp
Normal file
19
concordia/concordia_exception.cpp
Normal file
@ -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;
|
||||
}
|
36
concordia/concordia_exception.hpp
Normal file
36
concordia/concordia_exception.hpp
Normal file
@ -0,0 +1,36 @@
|
||||
#ifndef CONCORDIA_EXCEPTION_HDR
|
||||
#define CONCORDIA_EXCEPTION_HDR
|
||||
|
||||
#include<exception>
|
||||
#include<string>
|
||||
#include<string.h>
|
||||
|
||||
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
|
12
concordia/main.dox
Normal file
12
concordia/main.dox
Normal file
@ -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.
|
||||
|
||||
*/
|
32
concordia/running.dox
Normal file
32
concordia/running.dox
Normal file
@ -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/).
|
6
concordia/t/CMakeLists.txt
Normal file
6
concordia/t/CMakeLists.txt
Normal file
@ -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)
|
19
concordia/t/test_concordia.cpp
Normal file
19
concordia/t/test_concordia.cpp
Normal file
@ -0,0 +1,19 @@
|
||||
#include "tests/unit-tests/unit_tests_globals.hpp"
|
||||
#include "concordia/concordia.hpp"
|
||||
#include "tests/common/test_resources_manager.hpp"
|
||||
|
||||
|
||||
#include <string>
|
||||
|
||||
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()
|
52
concordia/t/test_concordia_config.cpp
Normal file
52
concordia/t/test_concordia_config.cpp
Normal file
@ -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 <string>
|
||||
#include <list>
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
|
||||
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()
|
28
concordia/technical.dox
Normal file
28
concordia/technical.dox
Normal file
@ -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
|
11
prod/resources/concordia-config/concordia.cfg.in
Normal file
11
prod/resources/concordia-config/concordia.cfg.in
Normal file
@ -0,0 +1,11 @@
|
||||
#----------------------------
|
||||
# Concordia configuration file
|
||||
#---------------------------
|
||||
#
|
||||
|
||||
#Path to the Puddle tagset
|
||||
puddle_tagset_path = "@PROD_PUDDLE_TAGSET_PATH@";
|
||||
|
||||
|
||||
|
||||
### eof
|
7
prod/resources/puddle/tagset.txt
Normal file
7
prod/resources/puddle/tagset.txt
Normal file
@ -0,0 +1,7 @@
|
||||
[ATTR]
|
||||
|
||||
case = nom gen dat acc inst loc voc
|
||||
|
||||
[POS]
|
||||
|
||||
subst = case
|
Loading…
Reference in New Issue
Block a user