diff --git a/libcorpus2_whole/io/poliqarpcorpusreader.cpp b/libcorpus2_whole/io/poliqarpcorpusreader.cpp index 2bf578647636f46a51950f79e30c9e47a6da771b..acc6e36288486fed014b25c1ef412c090d8eb776 100644 --- a/libcorpus2_whole/io/poliqarpcorpusreader.cpp +++ b/libcorpus2_whole/io/poliqarpcorpusreader.cpp @@ -17,7 +17,10 @@ boost::shared_ptr<Corpus> PoliqarpCorpusReader::read(const std::string& corpus_f this->pq_doc_reader_ = boost::shared_ptr<PoliqarpDocumentReader>( new PoliqarpDocumentReader(tagset_, corpus_file)); - while ((doc = this->pq_doc_reader_->read())) { + while (1) { + if (!(doc = this->pq_doc_reader_->read())) { + break; + } corpus->add_document(doc); } diff --git a/libcorpus2_whole/io/poliqarpdocumentreader.cpp b/libcorpus2_whole/io/poliqarpdocumentreader.cpp index 62953d721789726b176dbfc6b5b471b9e5cf5327..8e41832d758893389129d36b011aebaba4e28173 100644 --- a/libcorpus2_whole/io/poliqarpdocumentreader.cpp +++ b/libcorpus2_whole/io/poliqarpdocumentreader.cpp @@ -12,9 +12,11 @@ PoliqarpDocumentReader::PoliqarpDocumentReader(const Tagset& tagset, const std:: boost::shared_ptr<Document> PoliqarpDocumentReader::read() { - boost::shared_ptr<Document> document = boost::make_shared<Document>(); + boost::shared_ptr<Document> document; boost::shared_ptr<Chunk> chunk = this->pqr_->get_next_chunk(); + if (chunk) { + document = boost::make_shared<Document>(); document->add_paragraph(chunk); } return document;