Skip to content
Snippets Groups Projects
Commit f4bfb87e authored by ilor's avatar ilor
Browse files

Merge branch 'master' of nlp.pwr.wroc.pl:corpus2

parents f6c21cd8 99388c53
No related merge requests found
...@@ -222,6 +222,22 @@ boost::shared_ptr<Chunk> BufferedChunkReader::get_next_chunk() ...@@ -222,6 +222,22 @@ boost::shared_ptr<Chunk> BufferedChunkReader::get_next_chunk()
} }
} }
bool BufferedChunkReader::has_more()
{
ensure_more();
return !chunk_buf_.empty();
}
bool BufferedSentenceReader::has_more()
{
if (sentence_buf_ != NULL) {
return true;
}
sentence_buf_ = actual_next_sentence();
return (sentence_buf_ != NULL);
}
BufferedSentenceReader::BufferedSentenceReader(const Tagset& tagset) BufferedSentenceReader::BufferedSentenceReader(const Tagset& tagset)
: TokenReader(tagset), chunkify_(true) : TokenReader(tagset), chunkify_(true)
, sentence_buf_(), token_buf_() , sentence_buf_(), token_buf_()
......
...@@ -90,6 +90,13 @@ public: ...@@ -90,6 +90,13 @@ public:
*/ */
virtual boost::shared_ptr<Chunk> get_next_chunk() = 0; virtual boost::shared_ptr<Chunk> get_next_chunk() = 0;
/**
* Checks if there is anything left to be returned. Non-const because it
* might read ahead and fill the buffer.
*/
virtual bool has_more() = 0;
/** /**
* General option setter. * General option setter.
*/ */
...@@ -297,6 +304,8 @@ public: ...@@ -297,6 +304,8 @@ public:
boost::shared_ptr<Chunk> get_next_chunk(); boost::shared_ptr<Chunk> get_next_chunk();
bool has_more();
void set_option(const std::string& option) { void set_option(const std::string& option) {
TokenReader::set_option(option); TokenReader::set_option(option);
} }
...@@ -332,6 +341,8 @@ public: ...@@ -332,6 +341,8 @@ public:
Sentence::Ptr get_next_sentence(); Sentence::Ptr get_next_sentence();
bool has_more();
boost::shared_ptr<Chunk> get_next_chunk(); boost::shared_ptr<Chunk> get_next_chunk();
void set_option(const std::string& option) { void set_option(const std::string& option) {
......
...@@ -61,6 +61,7 @@ namespace Corpus2 { ...@@ -61,6 +61,7 @@ namespace Corpus2 {
virtual Token* get_next_token() = 0; virtual Token* get_next_token() = 0;
virtual Sentence::Ptr get_next_sentence() = 0; virtual Sentence::Ptr get_next_sentence() = 0;
virtual boost::shared_ptr<Chunk> get_next_chunk() = 0; virtual boost::shared_ptr<Chunk> get_next_chunk() = 0;
virtual bool has_more() = 0;
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
virtual void set_option(const std::string& option); virtual void set_option(const std::string& option);
......
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