Skip to content
Snippets Groups Projects
Commit 844c9363 authored by michal's avatar michal
Browse files

fixed bug with reading documents without id - temporary solution, whole...

fixed bug with reading documents without id - temporary solution, whole DocumentReader class should be rebuilt
parent 8d0e3cf5
Branches
No related merge requests found
......@@ -73,8 +73,29 @@ boost::shared_ptr<Document> DocumentReader::read()
throw Corpus2Error(corpus_type_ + " is an unknown reader type!");
}
boost::shared_ptr<Document> DocumentReader::read_with_auto_id()
{
std::string line;
#ifdef WITH_POLIQARP
if (corpus_type_ == "poliqarp") {
return this->reader->read();
}
#endif
if (corpus_type_ == "document") {
if (std::getline(corpus_file, line)) {
boost::shared_ptr<CclRelReader> cclrel_reader = get_cclrel_reader(line);
cclrel_reader->get_option("autogen_sent_id");
cclrel_reader->set_option("autogen_chunk_id");
return cclrel_reader->read();
} else {
return boost::make_shared<Document>("End");
}
}
throw Corpus2Error(corpus_type_ + " is an unknown reader type!");
}
boost::shared_ptr<DocumentReaderI> DocumentReader::get_cclrel_reader(std::string& line)
boost::shared_ptr<CclRelReader> DocumentReader::get_cclrel_reader(std::string& line)
{
std::string ann_path, rel_path;
......
......@@ -20,6 +20,7 @@ or FITNESS FOR A PARTICULAR PURPOSE.
#include <string>
#include <libcorpus2_whole/corpus.h>
#include <libcorpus2_whole/io/reader_i.h>
#include <libcorpus2_whole/io/cclrelreader.h>
namespace Corpus2 {
namespace whole {
......@@ -30,10 +31,11 @@ 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();
boost::shared_ptr<Document> read_with_auto_id();
private:
boost::shared_ptr<DocumentReaderI> get_cclrel_reader(std::string& line);
boost::shared_ptr<CclRelReader> get_cclrel_reader(std::string& line);
boost::shared_ptr<DocumentReaderI> reader;
std::ifstream corpus_file;
private:
......
......@@ -22,6 +22,7 @@ namespace whole {
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_with_auto_id();
};
} // whole ns
} // Corpus2 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