#include "concordia-server/concordia_server.hpp" #include #include #include #include #include ConcordiaServer::ConcordiaServer(const std::string & configFilePath) throw(ConcordiaException) { _concordia = boost::shared_ptr ( new Concordia(configFilePath)); } ConcordiaServer::~ConcordiaServer() { } string ConcordiaServer::handleRequest(string & requestString) { stringstream ss; try { ss << "Content-type: text/html\r\n" << "\r\n" << "\n" << " \n" << " Hello, World!\n" << " \n" << " \n" << "

Hello, World!

\n" << " The concordia version is: "<< _concordia->getVersion() << "\n" << "

Input data:

\n" << requestString; ss << "

Adding content as example:

\n"; Example example1(requestString, 0); Example example2("Ala ma kota", 1); Example example3("Marysia nie ma kota chyba", 2); _concordia->addExample(example1); _concordia->addExample(example2); _concordia->addExample(example3); _concordia->refreshSAfromRAM(); ss << "

Searching ma kota:

\n"; boost::ptr_vector result = _concordia->simpleSearch("ma kota"); BOOST_FOREACH(SubstringOccurence occurence, result) { ss << "\t\tfound match in sentence number: " << occurence.getId() << "

"; } ss << " \n" << "\n"; } catch (ConcordiaException & e) { ss << "

Concordia error:" << e.what() << "

"; } return ss.str(); }