Learn R Programming

polmineR (version 0.7.11)

kwic: KWIC/concordance output.

Description

Prepare and show concordances / keyword-in-context (kwic).

Usage

kwic(.Object, ...)

# S4 method for context kwic(.Object, s_attributes = getOption("polmineR.meta"), cpos = TRUE, verbose = FALSE, ...)

# S4 method for partition kwic(.Object, query, cqp = is.cqp, left = getOption("polmineR.left"), right = getOption("polmineR.right"), s_attributes = getOption("polmineR.meta"), p_attribute = "word", boundary = NULL, cpos = TRUE, stoplist = NULL, positivelist = NULL, regex = FALSE, verbose = TRUE, ...)

# S4 method for character kwic(.Object, query, cqp = is.cqp, check = TRUE, left = as.integer(getOption("polmineR.left")), right = as.integer(getOption("polmineR.right")), s_attributes = getOption("polmineR.meta"), p_attribute = "word", boundary = NULL, cpos = TRUE, stoplist = NULL, positivelist = NULL, regex = FALSE, verbose = TRUE, progress = TRUE, ...)

Arguments

.Object

A (length-one) character vector with the name of a CWB corpus, a partition or context object.

...

Further arguments, used to ensure backwards compatibility.

s_attributes

Structural attributes (s-attributes) to include into output table as metainformation.

cpos

Logical, if TRUE, the corpus positions ("cpos") if the hits will be included in the kwic-object that is returned.

verbose

Logical, whether to output progress messages

query

A query, CQP-syntax can be used.

cqp

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

left

Number of tokens to the left of query match.

right

Number of tokens to the right of query match.

p_attribute

The p-attribute, defaults to 'word'.

boundary

If provided, a length-one character vector stating an s-attribute that will be used to check the boundaries of the text.

stoplist

Terms or ids to prevent a concordance from occurring in results.

positivelist

Terms or ids required for a concordance to occurr in results

regex

Logical, whether stoplist/positivelist is interpreted as regular expression

check

A logical value, whether to check validity of CQP query using check_cqp_query.

progress

Logical, whether to show progress bars.

Details

The method works with a whole CWB corpus defined by a character vector, and can be applied on a partition- or a context object.

If a positivelist ist supplied, only concordances will be kept if at least one of the terms from the positivelist occurrs in the context of the query match. Use argument regex if the positivelist should be interpreted as regular expressions. Tokens from the positivelist will be highlighted in the output table.

References

Baker, Paul (2006): Using Corpora in Discourse Analysis. London: continuum, pp. 71-93 (ch. 4).

Jockers, Matthew L. (2014): Text Analysis with R for Students of Literature. Cham et al: Springer, pp. 73-87 (chs. 8 & 9).

See Also

The return value is a kwic-class object; the documentation for the class explains the methods applicable to kwic-class objects. To read the whole text, see the read-method.

Examples

Run this code
# NOT RUN {
use("polmineR")
K <- kwic("GERMAPARLMINI", "Integration")
K <- kwic(
  "GERMAPARLMINI",
  "Integration", left = 20, right = 20,
  s_attributes = c("date", "speaker", "party")
)
K <- kwic(
  "GERMAPARLMINI",
  '"Integration" [] "(Menschen|Migrant.*|Personen)"', cqp = TRUE,
  left = 20, right = 20,
  s_attributes = c("date", "speaker", "party")
)

K <- kwic(
  "GERMAPARLMINI",
  '"Sehr" "geehrte"', cqp = TRUE,
  boundary = "date"
)

P <- partition("GERMAPARLMINI", date = "2009-11-10")
K <- kwic(P, query = "Integration")
K <- kwic(P, query = '"Sehr" "geehrte"', cqp = TRUE, boundary = "date")
# }

Run the code above in your browser using DataLab