concordia-library/concordia/concordia.hpp

120 lines
3.8 KiB
C++
Raw Normal View History

2013-10-24 17:08:58 +02:00
#ifndef CONCORDIA_HDR
#define CONCORDIA_HDR
#include <string>
2013-11-28 16:47:57 +01:00
#include <vector>
2013-10-24 17:08:58 +02:00
#include <boost/shared_ptr.hpp>
#include <boost/filesystem.hpp>
2013-10-24 17:08:58 +02:00
#include "concordia/common/config.hpp"
#include "concordia/example.hpp"
#include "concordia/substring_occurence.hpp"
2013-10-24 17:08:58 +02:00
#include "concordia/concordia_config.hpp"
2013-11-28 16:47:57 +01:00
#include "concordia/concordia_index.hpp"
#include "concordia/index_searcher.hpp"
#include "concordia/concordia_search_result.hpp"
#include "concordia/anubis_search_result.hpp"
#include <divsufsort.h>
2013-11-28 16:47:57 +01:00
2013-10-24 17:08:58 +02:00
/*!
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();
2015-04-30 22:22:54 +02:00
/*! Adds an Example to the index.
\param example example to be added
\throws ConcordiaException
*/
void addExample(const Example & example) throw(ConcordiaException);
2013-11-28 16:47:57 +01:00
2015-04-30 22:22:54 +02:00
/*! Adds multiple examples to the index.
\param examples vector of examples to be added
\throws ConcordiaException
*/
void addAllExamples(const std::vector<Example> & examples)
throw(ConcordiaException);
2015-04-30 22:22:54 +02:00
/*! Performs a simple substring lookup on the index.
For more info see \ref tutorial1_2.
\param pattern pattern to be searched in the index
\returns vector of matched results
\throws ConcordiaException
*/
std::vector<SubstringOccurence> simpleSearch(const std::string & pattern)
throw(ConcordiaException);
2013-11-28 16:47:57 +01:00
2015-04-30 22:22:54 +02:00
/*! \deprecated
Finds the examples from the index, whose resemblance to the
pattern is maximal. This method may perform very slow,
try using concordiaSearch instead.
\param pattern pattern to be searched in the index
\returns vector of anubis results
\throws ConcordiaException
*/
std::vector<AnubisSearchResult> anubisSearch(const std::string & pattern)
throw(ConcordiaException);
2015-04-30 22:22:54 +02:00
/*! Performs concordia lookup on the index. This is a unique library
functionality, designed to facilitate Computer-Aided Translation.
For more info see \ref tutorial1_3.
\param pattern pattern to be searched in the index
\returns concordia result
\throws ConcordiaException
*/
boost::shared_ptr<ConcordiaSearchResult> concordiaSearch(
const std::string & pattern)
throw(ConcordiaException);
2015-04-30 22:22:54 +02:00
/*! Loads HDD stored index files to RAM and generates
suffix array based on RAM stored data structures.
For more info see \ref tutorial2.
\throws ConcordiaException
*/
void loadRAMIndexFromDisk() throw(ConcordiaException);
2015-04-30 22:22:54 +02:00
/*! Generates suffix array based on RAM stored data structures.
For more info see \ref tutorial2.
\throws ConcordiaException
*/
void refreshSAfromRAM() throw(ConcordiaException);
2013-11-28 16:47:57 +01:00
2013-10-24 17:08:58 +02:00
private:
void _initializeIndex() throw(ConcordiaException);
2013-10-24 17:08:58 +02:00
static std::string _libraryVersion;
boost::shared_ptr<ConcordiaConfig> _config;
2013-11-28 16:47:57 +01:00
boost::shared_ptr<ConcordiaIndex> _index;
boost::shared_ptr<IndexSearcher> _searcher;
boost::shared_ptr<HashGenerator> _hashGenerator;
boost::shared_ptr<std::vector<sauchar_t> > _T;
boost::shared_ptr<std::vector<saidx_t> > _SA;
boost::shared_ptr<std::vector<SUFFIX_MARKER_TYPE> > _markers;
2013-10-24 17:08:58 +02:00
};
#endif