ace::Buffer Class Reference

Class implements words buffer. More...

#include <buffer.h>

List of all members.

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.


Detailed Description

Class implements words buffer.

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.


Member Typedef Documentation

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.


Constructor & Destructor Documentation

ace::Buffer::Buffer ( Parser parser,
ContextWindow  context_window 
) [inline]

Creates buffer, which pushes some data in (from parser).

Parameters:
parser Parser to be used as data source.
context_window Used to keep buffer size big enough for context tracing.


Member Function Documentation

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.

Parameters:
iter Iterator to word within buffer (must be valid!).
Returns:
Index of given word (pointed by iterator) within the buffer.

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!).

Returns:
Number of words in popped sentence.

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()).

Parameters:
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]

Returns:
Words range corresponding to whole buffer (SENTENCE MODE).

words_range_t ace::Buffer::context_range ( words_store_t::const_iterator  head  )  const [inline]

Parameters:
head Head member of N-gram.
Returns:
Words range coresponding to context window and given (N-gram) head (WORD MODE).

words_range_t ace::Buffer::context_range ( words_store_t::const_iterator  left,
words_store_t::const_iterator  right 
) const

Parameters:
left Left-most N-gram member.
right Left-most N-gram member.
Returns:
Words range coresponding to context window and given boundary N-gram members.

bool ace::Buffer::empty ( void   )  const [inline]

Returns:
True, if buffer is empty.

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).

Returns:
True, if current sentence pointer move performed successfully.

words_range_t ace::Buffer::current ( void   )  const

Returns:
Current sentence range.

DataFileStats ace::Buffer::stats ( void   )  const [inline]

Returns:
Copy of stats for data pushed in (so far).


Member Data Documentation

Underlying parser.

Container for words.

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.

Context window is needed to provide efficient pop/push operations.

Stats of pushed-in data.


The documentation for this class was generated from the following files:

Generated on Wed Aug 6 23:25:50 2008 for PACE by  doxygen 1.5.6