Skip to content
Snippets Groups Projects
Commit 99388c53 authored by Adam Radziszewski's avatar Adam Radziszewski
Browse files

add has_more to readers

parent bca77ee2
No related merge requests found
......@@ -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)
: TokenReader(tagset), chunkify_(true)
, sentence_buf_(), token_buf_()
......
......@@ -90,6 +90,13 @@ public:
*/
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.
*/
......@@ -297,6 +304,8 @@ public:
boost::shared_ptr<Chunk> get_next_chunk();
bool has_more();
void set_option(const std::string& option) {
TokenReader::set_option(option);
}
......@@ -332,6 +341,8 @@ public:
Sentence::Ptr get_next_sentence();
bool has_more();
boost::shared_ptr<Chunk> get_next_chunk();
void set_option(const std::string& option) {
......
......@@ -61,6 +61,7 @@ namespace Corpus2 {
virtual Token* get_next_token() = 0;
virtual Sentence::Ptr get_next_sentence() = 0;
virtual boost::shared_ptr<Chunk> get_next_chunk() = 0;
virtual bool has_more() = 0;
/* --------------------------------------------------------------------- */
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