<div dir="ltr">Stefan,<br><br>Thank you very much! (again)!<br><br>Where can I find some documentation on this? So I won't bother you ;)<br><br>Eva<br><br><br><br><div class="gmail_quote">On Mon, Sep 6, 2010 at 5:08 PM, Stefan Evert <span dir="ltr"><<a href="mailto:stefanML@collocations.de" target="_blank">stefanML@collocations.de</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div>> I'm trying to use the Perl API for version 3.0 and I have encountered a problem:<br>
><br>
> 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);<br>
> 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.<br>
<br>
</div>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.<br>
<br>
The "standard" way of running queries in CWB::CQP is the following:<br>
<br>
$cqp = new CWB::CQP; # or whatever initialisation you need<br>
# activate your corpus etc.<br>
<br>
$cqp->exec("Matches = <your query>");<br>
($n_matches) = $cqp->exec("size Matches");<br>
# now you can skip processing if there are 0 matches, or "reduce Matches" if there are too many<br>
@lines = $cqp->exec("cat Matches"); # or use "tabulate" to get exactly the information you need<br>
<br>
# somewhat slower but more memory-efficient for large result sets:<br>
$cqp->run("cat Matches");<br>
while (defined $line = $cqp->getline) {<br>
# process this result line<br>
}<br>
<br>
If you want to see interactively what this special mode looks like, run CQP as follows:<br>
<br>
cqp -c # -c = "child process mode"<br>
set PrettyPrint off;<br>
<br>
Note that there are no input prompts or command-line editing facilities in this mode.<br>
<br>
Best,<br>
Stefan<br>
<br>
_______________________________________________<br>
CWB mailing list<br>
<a href="mailto:CWB@sslmit.unibo.it" target="_blank">CWB@sslmit.unibo.it</a><br>
<a href="http://devel.sslmit.unibo.it/mailman/listinfo/cwb" target="_blank">http://devel.sslmit.unibo.it/mailman/listinfo/cwb</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>Eva Kelman<br><br>Ph.D. Student,<br>Interdisciplinary Center for Neural Computation, Jerusalem<br>
</div>