[CWB] Using the Perl API

Eva Kelman eva.kelman at gmail.com
Tue Sep 14 15:20:51 CEST 2010


Stefan,

Thank you very much! (again)!

Where can I find some documentation on this? So I won't bother you ;)

Eva



On Mon, Sep 6, 2010 at 5:08 PM, Stefan Evert <stefanML at collocations.de>wrote:

> > I'm trying to use the Perl API for version 3.0 and I have encountered a
> problem:
> >
> > The "system commands" (such as show corpora, choosing a corpus to use and
> so on) work fine and I can receive their output (using getline or the output
> of exec method);
> > however, running  a query (no matter how simple it is and no matter how
> many results I get when running it from the CQP command line), I get nothing
> from the API methods.
>
> The Perl interface runs CQP in a special mode as a backend process.  One of
> the consequences is that the results of a query are no longer displayed
> automatically -- you have to run a "cat" command explicitly.
>
> The "standard" way of running queries in CWB::CQP is the following:
>
>        $cqp = new CWB::CQP;  # or whatever initialisation you need
>        # activate your corpus etc.
>
>        $cqp->exec("Matches = <your query>");
>        ($n_matches) = $cqp->exec("size Matches");
>        # now you can skip processing if there are 0 matches, or "reduce
> Matches" if there are too many
>        @lines = $cqp->exec("cat Matches"); # or use "tabulate" to get
> exactly the information you need
>
>        # somewhat slower but more memory-efficient for large result sets:
>        $cqp->run("cat Matches");
>        while (defined $line = $cqp->getline) {
>                # process this result line
>        }
>
> If you want to see interactively what this special mode looks like, run CQP
> as follows:
>
>        cqp -c  # -c = "child process mode"
>        set PrettyPrint off;
>
> Note that there are no input prompts or command-line editing facilities in
> this mode.
>
> Best,
> Stefan
>
> _______________________________________________
> CWB mailing list
> CWB at sslmit.unibo.it
> http://devel.sslmit.unibo.it/mailman/listinfo/cwb
>



-- 
Eva Kelman

Ph.D. Student,
Interdisciplinary Center for Neural Computation, Jerusalem
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://liste.sslmit.unibo.it/pipermail/cwb/attachments/20100914/cd7e5fb6/attachment.htm


More information about the CWB mailing list