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 |
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.
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.
CQP Query Language Tutorial (http://cwb.sourceforge.net/files/CQP_Tutorial.pdf)
is.cqp("migration") # will return FALSE#> [1] FALSEis.cqp('"migration"') # will return TRUE#> [1] TRUEis.cqp('[pos = "ADJA"] "migration"') # will return TRUE#> [1] TRUEas.cqp("migration")#> migration #> "\"migration\""#> migration diversity #> "\"migration\"" "\"diversity\""#> [1] "(\"migration\"|\"diversity\")"as.cqp("migration", normalise.case = TRUE)#> migration #> "\"migration\" %c"check_cqp_query('"Integration.*"') # TRUE, the query is ok#> "Integration.*" #> TRUEcheck_cqp_query('"Integration.*') # FALSE, closing quotation mark is missing#> Warning: An issue occurred when checking query: "Integration.* #> Number of quotation marks is not divisable by 2: Opening quotation marks are not matched by closing quotation marks, or vice versa. Aborting to avoid a potential crash of CQP and the entire R session. Please check query.#> "Integration.* #> FALSEcheck_cqp_query("'Integration.*") # FALSE, closing quotation mark is missing#> Warning: An issue occurred when checking query: 'Integration.* #> Number of quotation marks is not divisable by 2: Opening quotation marks are not matched by closing quotation marks, or vice versa. Aborting to avoid a potential crash of CQP and the entire R session. Please check query.#> 'Integration.* #> FALSE#> Warning: An issue occurred when checking query: 'Integration.* #> Number of quotation marks is not divisable by 2: Opening quotation marks are not matched by closing quotation marks, or vice versa. Aborting to avoid a potential crash of CQP and the entire R session. Please check query.#> Warning: An issue occurred when checking query: "Integration.* #> Number of quotation marks is not divisable by 2: Opening quotation marks are not matched by closing quotation marks, or vice versa. Aborting to avoid a potential crash of CQP and the entire R session. Please check query.#> 'Integration.* "Integration.* #> FALSE FALSE