Tools for CQP queries.
Test whether a character string is a CQP query, or turn a character vector into CQP queries.
is.cqp(query) check_cqp_query(query, warn = TRUE) as.cqp(query, normalise.case = FALSE, collapse = FALSE)
query |
A |
warn |
A (length-one) |
normalise.case |
A |
collapse |
A |
The is.cqp
function guesses whether query
is a CQP query
and returns the respective logical value (TRUE
/FALSE
).
The as.cqp
function takes a character vector as input and converts it
to a CQP query by putting the individual strings in quotation marks.
The check_cqp_query
-function will check that opening
quotation marks are matched by closing quotation marks, to prevent crashes
of CQP and the R session.
is.cqp
returns a logical value, as.cqp
a character
vector, check_cqp_query
a logical value that is TRUE
if all
queries are valid, or FALSE
if not.
CQP Query Language Tutorial (http://cwb.sourceforge.net/files/CQP_Tutorial.pdf)
is.cqp("migration") # will return FALSE is.cqp('"migration"') # will return TRUE is.cqp('[pos = "ADJA"] "migration"') # will return TRUE as.cqp("migration") as.cqp(c("migration", "diversity")) as.cqp(c("migration", "diversity"), collapse = TRUE) as.cqp("migration", normalise.case = TRUE) check_cqp_query('"Integration.*"') # TRUE, the query is ok check_cqp_query('"Integration.*') # FALSE, closing quotation mark is missing check_cqp_query("'Integration.*") # FALSE, closing quotation mark is missing check_cqp_query(c("'Integration.*", '"Integration.*')) # FALSE too
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.