Skip to content
Snippets Groups Projects
Commit ed82f26b authored by Lukasz Bilenkij's avatar Lukasz Bilenkij
Browse files

handling poliqarp readers

parent 930fb98d
Branches
No related merge requests found
......@@ -25,6 +25,21 @@ or FITNESS FOR A PARTICULAR PURPOSE.
namespace Corpus2 {
namespace whole{
DocumentReader::DocumentReader(const Tagset& tagset, const std::string& corpus_type, const std::string& corpus_file_path, const std::string& corpus_reader)
: corpus_type_(corpus_type), tagset_(tagset), corpus_path_(corpus_file_path)
{
if (corpus_type_ == "document") {
corpus_file.open(corpus_file_path.c_str());
#ifdef WITH_POLIQARP
} else if (corpus_type_ == "poliqarp") {
reader = boost::shared_ptr<PoliqarpDocumentReader>(
new PoliqarpDocumentReader(tagset_, corpus_path_, corpus_reader));
#endif
} else {
throw Corpus2Error(corpus_type_ + " is an unknown reader type!");
}
}
DocumentReader::DocumentReader(const Tagset& tagset, const std::string& corpus_type, const std::string& corpus_file_path)
: corpus_type_(corpus_type), tagset_(tagset), corpus_path_(corpus_file_path)
{
......@@ -33,7 +48,7 @@ DocumentReader::DocumentReader(const Tagset& tagset, const std::string& corpus_t
#ifdef WITH_POLIQARP
} else if (corpus_type_ == "poliqarp") {
reader = boost::shared_ptr<PoliqarpDocumentReader>(
new PoliqarpDocumentReader(tagset_, corpus_path_));
new PoliqarpDocumentReader(tagset_, corpus_path_, "poliqarp"));
#endif
} else {
throw Corpus2Error(corpus_type_ + " is an unknown reader type!");
......
......@@ -11,8 +11,8 @@ namespace whole {
class DocumentReader
{
public:
DocumentReader(const Tagset& tagset, const std::string& corpus_type, const std::string& corpus_file_path, const std::string& corpus_reader);
DocumentReader(const Tagset& tagset, const std::string& corpus_type, const std::string& corpus_file_path);
boost::shared_ptr<Document> read();
private:
......
......@@ -4,10 +4,17 @@
namespace Corpus2 {
namespace whole {
PoliqarpDocumentReader::PoliqarpDocumentReader(const Tagset& tagset, const std::string& corpus_path, const std::string& corpus_reader)
: DocumentReaderI("poliqarp")
{
this->pqr_ = Corpus2::TokenReader::create_path_reader(corpus_reader, tagset, corpus_path);
}
PoliqarpDocumentReader::PoliqarpDocumentReader(const Tagset& tagset, const std::string& corpus_path)
: DocumentReaderI("poliqarp")
{
this->pqr_ = boost::shared_ptr<PoliqarpReader>(new PoliqarpReader(tagset, corpus_path));
this->pqr_ = Corpus2::TokenReader::create_path_reader("poliqarp", tagset, corpus_path);
}
boost::shared_ptr<Document> PoliqarpDocumentReader::read()
......@@ -26,5 +33,6 @@ boost::shared_ptr<Document> PoliqarpDocumentReader::read()
return document;
}
} // whole ns
} // Corpus2 ns
......@@ -18,8 +18,8 @@ namespace whole {
class PoliqarpDocumentReader : public DocumentReaderI
{
public:
PoliqarpDocumentReader(const Tagset& tagset, const std::string& corpus_path, const std::string& corpus_reader);
PoliqarpDocumentReader(const Tagset& tagset, const std::string& corpus_path);
/**
* Semantic of this methd is similar to get_next_document from Poliqarp Client
* @return nth readed document
......@@ -35,7 +35,7 @@ public:
private:
/// Poliqarp reader used for reading Poliqarp corp
boost::shared_ptr<PoliqarpReader> pqr_;
Corpus2::TokenReader::TokenReaderPtr pqr_;
};
} // whole ns
......
......@@ -19,7 +19,8 @@ namespace Corpus2 {
namespace whole {
class DocumentReader {
public:
DocumentReader(const Tagset& tagset, const std::string& corpus_type,const std::string& corpus_file);
DocumentReader(const Tagset& tagset, const std::string& corpus_type,const std::string& corpus_file_path, const std::string& corpus_reader);
DocumentReader(const Tagset& tagset, const std::string& corpus_type,const std::string& corpus_file_path);
boost::shared_ptr<Document> read();
};
} // whole ns
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment