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

handling poliqarp readers

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