#include <buffer.h>
Public Member Functions | |
| Buffer (Parser &parser, ContextWindow context_window) | |
| Creates buffer, which pushes some data in (from parser). | |
| words_range_t | context_range (void) const |
| words_range_t | context_range (words_store_t::const_iterator head) const |
| words_range_t | context_range (words_store_t::const_iterator left, words_store_t::const_iterator right) const |
| bool | empty (void) const |
| bool | next (void) |
| Advances to the next sentence (move current sentence pointer, pushes in some data if needed, pops some data if possible). | |
| words_range_t | current (void) const |
| DataFileStats | stats (void) const |
Private Types | |
| typedef std::pair< size_t, size_t > | sentence_index_t |
| Index of sentence beginnning (determines first word of sentence within buffer) and length of sentence. | |
| typedef std::list < sentence_index_t > | sentences_indices_t |
| Buffer may hold multiple sentences. | |
Private Member Functions | |
| size_t | _index_of (words_store_t::const_iterator iter) const |
| Returns index of given word (pointed by iterator) within the buffer. | |
| void | _init (void) |
| Inits buffer and pushes in some data (amount is determined by context window settings). | |
| size_t | _pop (void) |
| Pops top sentence from queue (doesn't check if buffer is non-empty!). | |
| void | _push (size_t needed=1, ContextWindow::Mode context_window_mode=ContextWindow::SENTENCE_MODE) |
| Push next sentence(s) into the buffer, params determine(s) number of sentence(s) pushed - ther're forwarded to parser (see Parser::next()). | |
Private Attributes | |
| Parser & | _parser |
| Underlying parser. | |
| words_store_t | _words |
| Container for words. | |
| sentences_indices_t | _sentences |
| Sentences bounds. | |
| sentences_indices_t::iterator | _current |
| Current sentence (in every moment only one sentence is current!). | |
| const ContextWindow | _context_window |
| Context window is needed to provide efficient pop/push operations. | |
| DataFileStats | _stats |
| Stats of pushed-in data. | |
Words buffer is used for retrieval of data from datafiles (by using Parser, see parser.h). Buffer main purpose is to push in as much data as needed for tracing of N-grams context and to drop this data just in the moment when they become unneeded.
typedef std::pair<size_t, size_t> ace::Buffer::sentence_index_t [private] |
Index of sentence beginnning (determines first word of sentence within buffer) and length of sentence.
typedef std::list<sentence_index_t> ace::Buffer::sentences_indices_t [private] |
Buffer may hold multiple sentences.
They're indices are stored in list because we need insert/delete that keeps iterators valid.
| ace::Buffer::Buffer | ( | Parser & | parser, | |
| ContextWindow | context_window | |||
| ) | [inline] |
Creates buffer, which pushes some data in (from parser).
| parser | Parser to be used as data source. | |
| context_window | Used to keep buffer size big enough for context tracing. |
| size_t ace::Buffer::_index_of | ( | words_store_t::const_iterator | iter | ) | const [inline, private] |
Returns index of given word (pointed by iterator) within the buffer.
| iter | Iterator to word within buffer (must be valid!). |
| void ace::Buffer::_init | ( | void | ) | [private] |
Inits buffer and pushes in some data (amount is determined by context window settings).
| size_t ace::Buffer::_pop | ( | void | ) | [private] |
Pops top sentence from queue (doesn't check if buffer is non-empty!).
| void ace::Buffer::_push | ( | size_t | needed = 1, |
|
| ContextWindow::Mode | context_window_mode = ContextWindow::SENTENCE_MODE | |||
| ) | [private] |
Push next sentence(s) into the buffer, params determine(s) number of sentence(s) pushed - ther're forwarded to parser (see Parser::next()).
| needed | Amount of sentences (words) wanted to be pushed in. | |
| context_window_mode | Determines, if the `needed` param means words or sentences. |
| words_range_t ace::Buffer::context_range | ( | void | ) | const [inline] |
| words_range_t ace::Buffer::context_range | ( | words_store_t::const_iterator | head | ) | const [inline] |
| head | Head member of N-gram. |
| words_range_t ace::Buffer::context_range | ( | words_store_t::const_iterator | left, | |
| words_store_t::const_iterator | right | |||
| ) | const |
| left | Left-most N-gram member. | |
| right | Left-most N-gram member. |
| bool ace::Buffer::empty | ( | void | ) | const [inline] |
| bool ace::Buffer::next | ( | void | ) |
Advances to the next sentence (move current sentence pointer, pushes in some data if needed, pops some data if possible).
| words_range_t ace::Buffer::current | ( | void | ) | const |
| DataFileStats ace::Buffer::stats | ( | void | ) | const [inline] |
Parser& ace::Buffer::_parser [private] |
Underlying parser.
words_store_t ace::Buffer::_words [private] |
Container for words.
sentences_indices_t ace::Buffer::_sentences [private] |
Sentences bounds.
sentences_indices_t::iterator ace::Buffer::_current [private] |
Current sentence (in every moment only one sentence is current!).
There is no current sentence if buffer is empty.
const ContextWindow ace::Buffer::_context_window [private] |
Context window is needed to provide efficient pop/push operations.
DataFileStats ace::Buffer::_stats [private] |
Stats of pushed-in data.
1.5.6