[CWB] Question about CWB::CQP::More

Scott Sadowsky ssadowsky at gmail.com
Mon Dec 13 17:20:26 CET 2010


On 12/12/2010 02:26 PM, Stefan Evert wrote:

Hi Stefan and Alberto,

> In case this hasn't been answered yet -- I'm travelling and haven't
> been able to check e-mail for a day or two -- here's an explanation
> of Scott's mistake.  Don't worry, the mistake was very hard to spot
> and the question had me stumped at first.

Yes! Alberto was kind enough to show me the error of my ways, and now 
I've managed to get my script working perfectly.


 > This may in part be due to the fact that the Perl
> variable for the latter is somewhat counterintuitively named
> $query_type.

That was my doing, unfortunately...


> BTW, this is going to blow up in your face if $query_item ever
> contains double quotes or a single trailing backslash.  It's safer to
> quote the string properly through CWB::CQP:
>
> my $query_to_send_to_cqp = "[$query_type =
> ".$cqp->quote($query_item)."]";

This fails for me, producing a 0 byte output file (but no error message 
that I can see, and I'm using both "strict" and "warnings" in Perl).

(BTW, is there some way to make error messages more common or verbose? I 
rarely see them, but I suspect I *deserve* to be seeing a lot more).

This is my current, functional (but vulnerable) code:

$query_to_send_to_cqp = "QUERY = [$query_type = \"" . $query_item . 
"\"\%$case_diacr_string];";

($case_diacr_string is either "c", "d" or "cd", of course).

This is how I tried to incorporate the proper quoting function:

$query_to_send_to_cqp = "QUERY = [$query_type = \"" . 
$cqp->quote($query_item) . "\"\%$case_diacr_string];";

But I get the same 0-byte file as with the original code.

Could it be that I need another module to load, besides CWB::CQP::More?

Cheers,
Scott


-- 
Scott Sadowsky
Doctorando en Lingüística
Universidad de Concepción, Chile

http://ssadowsky.hostei.com/
ssadowsky at gmail.com
ssadowsky at udec.cl


More information about the CWB mailing list