CWB::CQP::More - A higher level interface for CWB::CQP


    use CWB::CQP::More;

    my $cqp = CWB::CQP::More->new( { utf8 => 1 } );


    # This needs to get fixed... not nice to say "'<b>'"
    $cqp->set(Context  => [20, 'words'],
              LD       => "'<b>'",
              RD       => "'</b>'");

    # using Try::Tiny...
    try {
        $cqp->exec('A = "dog";');
        my $result_size = $cqp->size('A');
        my @lines = $cqp->cat('A');
    } catch {
        print "Error: $_\n";


    $details = $cqp->corpora_details('hansards');

    $available_corpora = $cqp->show_corpora;

    # for debug
    use CWB::CQP::More 'DEBUG';


This class superclasses CWB::CQP and adds some higher-order functionalities.


The new constructor has the same behavior has the CWB::CQP new method, unless the first argument is a hash reference. In that case, it is shifted and used as configuration for CWB::CQP::More. The remaining arguments are sent unaltered to CWB::CQP constructor.


Set utf8 mode on or off. Pass it a 1 or a 0 as argument. Returns that same value. If used without arguments, returns current value.


Uses the size CQP command to fetch the size of a query result set. Pass it its name, returns an integer. -1 if the result set does not exist or an error occurred.


This method uses the cat method to return a result set. The first mandatory argument is the name of the result set. Second and Third arguments are optional, and correspond to the interval of matches to return.

Returns empty list on any error.


Use this method to specify what annotations to make CQP to show. Pass it a list of the annotation names.


Use this method to specify what annotations to make CQP to not show (hide). Pass it a list of the annotation names.


Change current active corpus. Pass the corpus name as the argument.


Set CQP properties. Pass a hash (not a reference) of key/values to be set. Note that at the moment string values should be double quoted (see example in the synopsis).


Similar to CWB::CQP->exec, but dying in case of error with the error message. Useful for use with Try::Tiny. Check the synopsis above for an example.


Returns a reference to a hash with details about a specific corpus, like name, id, home directory, properties and attributes;


Returns a reference to a list of the available corpora;


Returns a new iterator, to iterate over a result set. See CWB::CQP::More::Iterator for documentation on how to use it.


Alberto Simoes, <ambs at>


Please report any bugs or feature requests to bug-cwb-cqp-more at, or through the web interface at I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.


You can find documentation for this module with the perldoc command.

    perldoc CWB::CQP::More

You can also look for information at:


Thanks for Stefan Evert for all help.


Copyright 2010-2011 Alberto Simoes.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See for more information.