The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

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

SYNOPSIS

    use CWB::CQP::More;

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

    $cqp->change_corpus('HANSARDS');

    # 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";
    }

    $cqp->annotation_show("pos");

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

    $available_corpora = $cqp->show_corpora;

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

METHODS

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

new

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.

utf8

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.

size

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.

cat

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.

annotation_show

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

annotation_hide

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

change_corpus

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

set

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

exec

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.

corpora_details

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

show_corpora

Returns a reference to a list of the available corpora;

iterator

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

AUTHOR

Alberto Simoes, <ambs at cpan.org>

BUGS

Please report any bugs or feature requests to bug-cwb-cqp-more at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=CWB-CQP-More. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

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

    perldoc CWB::CQP::More

You can also look for information at:

ACKNOWLEDGEMENTS

Thanks for Stefan Evert for all help.

LICENSE AND COPYRIGHT

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 http://dev.perl.org/licenses/ for more information.