NAME
CWB::CQP::More::Iterator - Iterator for CWB::CQP resultsets
SYNOPSIS
use CWB::CQP::More;
my $cwb = CWB::CQP::More->new();
$cwb->change_corpus("foo");
$cwb->exec('A = "dog";');
my $iterator = $cwb->iterator("A");
my $next_line = $iterator->next;
my $iterator20 = $cwb->iterator("A", size => 20);
my @twenty = $iterator20->next;
my $iteratorFoo = $cwb->iterator("A", size => 20, corpus => 'foo');
my @lines = $iteratorFoo->next;
$iterator->reset;
$iterator->increment(20);
DESCRIPTION
This module implements an interator for CWB result sets. Please to not use the constructor directly. Instead, use the iterator
method on CWB::CQP::More
module.
new
Creates a new iterator. Used internally by the CWB::CQP::More
module, when the method iterator
is called.
next
Returns the next line(s) on the result set.
reset
Restarts the iterator.
peek
Use peek to peek the iterator. Pass it a offset (positive or negative). It will return the concordance at that position. Note that the current iterator position is not changed!
my $peek = $cwb->peek(100); # look 100 positions ahead
my $backpeek = $cwb->peek(-100); # look 100 positions behind
increment
Without arguments returns the current iterator increment size (number of lines returned by iteraction). With an argument, changes the size of the increment. The increment size can be changed while using the iterator.
forward
Forwards the iterator the offset specified. If the offset is too big (as in, more iterations than the size of the iterator) the iterator is set to the last element. It also supports negative offsets (but please use the backward
method).
The new position index is returned.
backward
Backwards the iterator the offset specified. If the offset is too big (as in, more iterations than the current position of the iterator) the iterator is set to the first element. It also supports negative offsets (but please use the forward
method).
The new position index is returned.
SEE ALSO
CWB::CQP::More (3), perl(1)
AUTHOR
Alberto Manuel Brandão Simões, <ambs@cpan.org>
COPYRIGHT AND LICENSE
Copyright (C) 2010 by Alberto Manuel Brandão Simões