cpos-method: get corpus positions

Description Usage Arguments Value

Description

If the cpos-method isapplied on "character", "partition", or "tempcorpus" object, the result is a two-column matrix with the start end end corpus positions of the matches for a query (CQP syntax can be used.) If the cpos-method is called on a "matrix" object, the cpos matrix is unfolded.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
cpos(.Object, ...)

## S4 method for signature 'character'
cpos(.Object, query,
  pAttribute = getOption("polmineR.pAttribute"), cqp = is.cqp,
  encoding = NULL, verbose = TRUE, ...)

## S4 method for signature 'partition'
cpos(.Object, query, cqp = is.cqp, pAttribute = NULL,
  verbose = TRUE, ...)

## S4 method for signature 'tempcorpus'
cpos(.Object, query, shift = TRUE)

## S4 method for signature 'matrix'
cpos(.Object)

Arguments

.Object

a "character" vector indicating a CWB corpus, a "partition" object, a "tempcorpus" object, or a "matrix" with corpus positions

...

further arguments

query

a character vector (length 1) providing a (single) query: either a single token to look up, or a CQP query.

pAttribute

the p-attribute to search. Needs to be stated only if query is not a CQP query. Defaults to NULL.

cqp

either logical (TRUE if query is a CQP query), or a function to check whether query is a CQP query or not (defaults to is.query auxiliary function)

encoding

the encoding of the corpus (if NULL, the encoding provided in the registry file of the corpus will be used)

verbose

logical, whether to be talkative

shift

logical, if true, the cpos resulting from the query performed on the tempcorpus will be shifted so that they match the positions of the corpus from which the tempcorpus was generated

Value

Unless .Object is a "matrix", you get a matrix with two columns, the first column giving the start cpos of the hits obtained, the second column giving the end cpos of the respective hit. The number of rows is the number of hits. If there are no hits, a NULL object will be returned.


nrauscher/corpus documentation built on May 23, 2019, 9:34 p.m.