S4 class for organizing information for kwic/concordance output. A set of standard generics (show, as.character, as.data.frame, length, sample, subset) as well as indexing is implemented to process kwic class objects (see 'Usage'). See section 'Details' for the enrich, view and knit_print methods.

# S4 method for kwic
get_corpus(x)

# S4 method for kwic
count(.Object, p_attribute = "word")

# S4 method for kwic
as.DocumentTermMatrix(x, p_attribute, verbose = TRUE, ...)

# S4 method for kwic
as.TermDocumentMatrix(x, p_attribute, verbose = TRUE, ...)

# S4 method for kwic
show(object)

# S4 method for kwic
knit_print(x, options = knitr::opts_chunk)

# S4 method for kwic
as.character(x, fmt = "<i>%s</i>")

# S4 method for kwic,ANY,ANY,ANY
[(x, i)

# S4 method for kwic
subset(x, ...)

# S4 method for kwic
as.data.frame(x)

# S4 method for kwic
length(x)

# S4 method for kwic
sample(x, size)

# S4 method for kwic_bundle
merge(x)

# S4 method for kwic
enrich(.Object, s_attributes = NULL, extra = NULL, table = FALSE, ...)

# S4 method for kwic
format(
  x,
  node_color = "blue",
  align = TRUE,
  extra_color = "grey",
  lineview = getOption("polmineR.lineview")
)

# S4 method for kwic
view(.Object)

Arguments

x

A kwic class object.

.Object

A kwic class object.

p_attribute

A length-one character vector supplying a p-attribute.

verbose

A logical value, whether to output debugging messages.

...

Used for backwards compatibility.

object

A kwic class object.

options

Chunk options.

fmt

A format string passed into sprintf to format the node of a KWIC display.

i

Single integer value, the kwic line for which the fulltext shall be inspected.

size

An integer, subset size for sampling.

s_attributes

Character vector of s-attributes with metainformation.

extra

An integer value, number of extra tokens to the left and to the right of the windows of tokens to the left and right of a query match that are decoded to be displayed in a kwic output to facilitate interpretation.

table

Logical, whether to turn cpos data.table into data.table in slot stat for output.

node_color

If not NULL, the html color of the node. If supplied, the node will be wrapped in respective html tags.

align

A logical value for preparing kwic output. If TRUE, whether the content of the columns 'left', 'node' and 'right' will be wrapped in html div elements that will align the output right, centered and left, respectively.

extra_color

If extra context has been generated using enrich, the html color of the additional output (defaults to 'grey').

lineview

A logical value, whether to concatenate left context, node and right context when preparing kwic output.

Details

Applying the count-method on a kwic object will return a count object with the evaluation of the left and right context of the match.

The knit_print method will be called by knitr to render `kwic` objects as a DataTable htmlwidget when rendering a R Markdown document as html. It will usually be necessary to explicitly state "render = knit_print" in the chunk options. The option `polmineR.pagelength` controls the number of lines displayed in the resulting `htmlwidget`. Note that including htmlwidgets in html documents requires that pandoc is installed. To avoid an error, a formatted data.table is returned by knit_print if pandoc is not available.

The as.character-method will return a list of character vectors, concatenating the columns "left", "node" and "right" of the data.table in the stat-slot of the input kwic-class object. Optionally, the node can be formatted using a format string that is passed into sprintf.

The subset-method will apply subset to the table in the slot stat, e.g. for filtering query results based on metadata (i.e. s-attributes) that need to be present.

The enrich method is used to generate the actual output for the kwic method. If param table is TRUE, corpus positions will be turned into a data.frame with the concordance lines. If param s_attributes is a character vector with s-attributes, the respective s-attributes will be added as columns to the table with concordance lines.

The format-method will return a data.table that can serve as input for rendering a htmlwidget, for instance using DT::datatable or rhandsontable::rhandsontable. It will include html tags, so ensure that the rendering engine does not obfuscate the html.

Slots

metadata

A character vector with s-attributes of the metadata that are to be displayed.

p_attribute

The p-attribute for which the context has been generated.

left

An integer value, words to the left of the query match.

right

An integer value, words to the right of the query match.

corpus

Length-one character vector, the CWB corpus.

cpos

A data.table with the columns "match_id", "cpos", "position", "word_id", "word" and "direction".

stat

A data.table, a table with columns "left", "node", "right", and metadata, if the object has been enriched.

encoding

A length-one character vector with the encoding of the corpus.

name

A length-one character vector naming the object.

annotation_cols

A character vector designating the columns of the data.table in the slot table that are annotations.

See also

The constructor for generating kwic objects is the kwic method.

Examples

use("polmineR")
#> ... activating corpus: GERMAPARLMINI (version: 0.0.1 | build date: 2019-02-23)
#> ... activating corpus: REUTERS
K <- kwic("GERMAPARLMINI", "Integration") get_corpus(K)
#> [1] "GERMAPARLMINI"
length(K)
#> [1] 23
K_min <- K[1] K_min <- K[1:5] # using kwic_bundle class queries <- c("oil", "prices", "barrel") li <- lapply(queries, function(q) kwic("REUTERS", query = q)) kb <- as.bundle(li) # use count-method on kwic object coi <- kwic("REUTERS", query = "oil") %>% count(p_attribute = "word") # features vs cooccurrences-method (identical results) ref <- count("REUTERS", p_attribute = "word") %>% subset(word != "oil") slot(ref, "size") <- slot(ref, "size") - count("REUTERS", "oil")[["count"]] y_features <- features(coi, ref, method = "ll", included = TRUE)
#> ... combining frequency lists
#> ... statistical test: ll
#> Warning: NaNs produced
y_cooc <- cooccurrences("REUTERS", query = "oil") # extract node and left and right context as character vectors oil <- kwic("REUTERS", query = "oil") as.character(oil, fmt = NULL)
#> [1] "its contract prices for crude oil by 1.50 dlrs a barrel" #> [2] "in the light of falling oil product prices and a weak" #> [3] "prices and a weak crude oil market a company spokeswoman said" #> [4] "in a line of U.S oil companies that have cut its" #> [5] "last two days citing weak oil markets Reuter OPEC may be" #> [6] "halt the current slide in oil prices oil industry analysts said" #> [7] "current slide in oil prices oil industry analysts said The movement" #> [8] "said The movement to higher oil prices was never to be" #> [9] "Research Associates CERA Analysts and oil industry sources said the problem" #> [10] "problem OPEC faces is excess oil supply in world oil markets" #> [11] "excess oil supply in world oil markets OPEC's problem is not" #> [12] "that way said Paul Mlotok oil analyst with Salomon Brothers Inc" #> [13] "to regain the initiative in oil prices But some other analysts" #> [14] "for one of the major oil companies who spoke on condition" #> [15] "winter demand to sell their oil but in late March and" #> [16] "that the demand for OPEC oil has been rising through the" #> [17] "production Demand for their OPEC oil is clearly above 15.8 mln" #> [18] "it will pay for crude oil 64 Canadian cts a barrel" #> [19] "Canada last changed its crude oil postings on Feb 19 Reuter" #> [20] "for all grades of crude oil one dlr a barrel effective" #> [21] "emergency OPEC meeting to review oil policies after recent weakness in" #> [22] "after recent weakness in world oil prices Sheikh Ali al Khalifa" #> [23] "Traders and analysts in international oil markets estimate OPEC is producing" #> [24] "a challenge to any international oil company that declared Kuwait sold" #> [25] "had guaranteed markets for its oil because of its local and" #> [26] "committee Referring to pressure by oil companies on OPEC members in" #> [27] "new report To counter falling oil revenues the government has launched" #> [28] "to boost exports outside the oil sector and attract new investment" #> [29] "year s fall in world oil prices which forced it to" #> [30] "industry Growth in the non oil sector is low because of" #> [31] "halting the current decline in oil prices Oil industry sources said" #> [32] "producers had had difficulty selling oil at official OPEC prices but" #> [33] "03 yesterday REUTER The Gulf oil state of Qatar recovering slightly" #> [34] "last year's decline in world oil prices announced its first budget" #> [35] "budget due to uncertainty surrounding oil revenues Sheikh Abdul Aziz said" #> [36] "was also no projection for oil revenue Qatar an OPEC member" #> [37] "expectations of positive signs regarding oil price trends foremost among them" #> [38] "OPEC accord to boost world oil prices and stabilise the market" #> [39] "recent fall in free market oil prices Nazer said Saudi Arabia" #> [40] "it will never sell its oil at prices below the pronounced" #> [41] "a year of turmoil on oil markets which saw prices slump" #> [42] "was shown clearly in the oil market He said contacts among" #> [43] "Traders and analysts in international oil markets estimate OPEC is producing" #> [44] "over producing REUTER Saudi crude oil output last month fell to" #> [45] "mln bpd in January Gulf oil sources said They said exports" #> [46] "December to back new official oil prices averaging 18 dlrs a" #> [47] "below Opec levels Saudi Arabian oil minister Hisham Nazer yesterday reiterated" #> [48] "export refineries They put crude oil exports through Yanbu at 100,000" #> [49] "200,000 bpd each REUTER Deputy oil ministers from six Gulf Arab" #> [50] "to discuss coordination of crude oil marketing the official Emirates news" #> [51] "by Gulf Cooperation Council GCC oil ministers to help each other" #> [52] "each other market their crude oil Four of the GCC states" #> [53] "OPEC accord to boost world oil prices and stabilize the market" #> [54] "recent fall in free market oil prices Nazer said Saudi Arabia" #> [55] "it will never sell its oil at prices below the pronounced" #> [56] "agreed to cut its total oil output ceiling by 7.25 pct" #> [57] "dollars a barrel Reuter Kuwait's oil minister said in a newspaper" #> [58] "the recent weakness in world oil prices Sheikh Ali al Khalifa" #> [59] "of crude daily bpd Crude oil prices fell sharply last week" #> [60] "sharply last week as international oil traders and analysts estimated the" #> [61] "was closed when a Cypriot oil tanker Seapride II ran aground" #> [62] "He said there was no oil spill but the ship is" #> [63] "the high tide After delivering oil to a refinery in Paulsboro" #> [64] "and future impact of low oil prices on the domestic oil" #> [65] "oil prices on the domestic oil industry U.S policy now is" #> [66] "called for new research for oil exploration and development techniques It" #> [67] "that such moves as increasing oil reserves and more exploration and" #> [68] "and future impact of low oil prices on the domestic oil" #> [69] "oil prices on the domestic oil industry U.S policy now is" #> [70] "called for new research for oil exploration and development techniques It" #> [71] "full economic benefits of cheap oil But the group did not" #> [72] "that such moves as increasing oil reserves and more exploration and" #> [73] "its posted prices for crude oil one to 1.50 dlrs a" #> [74] "West Coast grades of crude oil the company said Reuter The" #> [75] "April one NYMEX will allow oil traders that do not hold" #> [76] "This will change the way oil is transacted in the real" #> [77] "serve the industry because the oil market does not close when" #> [78] "CFTC spokeswoman Reuter Argentine crude oil production was down 10.8 pct"
as.character(oil) # node wrapped into <i> tag by default
#> [1] "its contract prices for crude <i>oil</i> by 1.50 dlrs a barrel" #> [2] "in the light of falling <i>oil</i> product prices and a weak" #> [3] "prices and a weak crude <i>oil</i> market a company spokeswoman said" #> [4] "in a line of U.S <i>oil</i> companies that have cut its" #> [5] "last two days citing weak <i>oil</i> markets Reuter OPEC may be" #> [6] "halt the current slide in <i>oil</i> prices oil industry analysts said" #> [7] "current slide in oil prices <i>oil</i> industry analysts said The movement" #> [8] "said The movement to higher <i>oil</i> prices was never to be" #> [9] "Research Associates CERA Analysts and <i>oil</i> industry sources said the problem" #> [10] "problem OPEC faces is excess <i>oil</i> supply in world oil markets" #> [11] "excess oil supply in world <i>oil</i> markets OPEC's problem is not" #> [12] "that way said Paul Mlotok <i>oil</i> analyst with Salomon Brothers Inc" #> [13] "to regain the initiative in <i>oil</i> prices But some other analysts" #> [14] "for one of the major <i>oil</i> companies who spoke on condition" #> [15] "winter demand to sell their <i>oil</i> but in late March and" #> [16] "that the demand for OPEC <i>oil</i> has been rising through the" #> [17] "production Demand for their OPEC <i>oil</i> is clearly above 15.8 mln" #> [18] "it will pay for crude <i>oil</i> 64 Canadian cts a barrel" #> [19] "Canada last changed its crude <i>oil</i> postings on Feb 19 Reuter" #> [20] "for all grades of crude <i>oil</i> one dlr a barrel effective" #> [21] "emergency OPEC meeting to review <i>oil</i> policies after recent weakness in" #> [22] "after recent weakness in world <i>oil</i> prices Sheikh Ali al Khalifa" #> [23] "Traders and analysts in international <i>oil</i> markets estimate OPEC is producing" #> [24] "a challenge to any international <i>oil</i> company that declared Kuwait sold" #> [25] "had guaranteed markets for its <i>oil</i> because of its local and" #> [26] "committee Referring to pressure by <i>oil</i> companies on OPEC members in" #> [27] "new report To counter falling <i>oil</i> revenues the government has launched" #> [28] "to boost exports outside the <i>oil</i> sector and attract new investment" #> [29] "year s fall in world <i>oil</i> prices which forced it to" #> [30] "industry Growth in the non <i>oil</i> sector is low because of" #> [31] "halting the current decline in <i>oil</i> prices Oil industry sources said" #> [32] "producers had had difficulty selling <i>oil</i> at official OPEC prices but" #> [33] "03 yesterday REUTER The Gulf <i>oil</i> state of Qatar recovering slightly" #> [34] "last year's decline in world <i>oil</i> prices announced its first budget" #> [35] "budget due to uncertainty surrounding <i>oil</i> revenues Sheikh Abdul Aziz said" #> [36] "was also no projection for <i>oil</i> revenue Qatar an OPEC member" #> [37] "expectations of positive signs regarding <i>oil</i> price trends foremost among them" #> [38] "OPEC accord to boost world <i>oil</i> prices and stabilise the market" #> [39] "recent fall in free market <i>oil</i> prices Nazer said Saudi Arabia" #> [40] "it will never sell its <i>oil</i> at prices below the pronounced" #> [41] "a year of turmoil on <i>oil</i> markets which saw prices slump" #> [42] "was shown clearly in the <i>oil</i> market He said contacts among" #> [43] "Traders and analysts in international <i>oil</i> markets estimate OPEC is producing" #> [44] "over producing REUTER Saudi crude <i>oil</i> output last month fell to" #> [45] "mln bpd in January Gulf <i>oil</i> sources said They said exports" #> [46] "December to back new official <i>oil</i> prices averaging 18 dlrs a" #> [47] "below Opec levels Saudi Arabian <i>oil</i> minister Hisham Nazer yesterday reiterated" #> [48] "export refineries They put crude <i>oil</i> exports through Yanbu at 100,000" #> [49] "200,000 bpd each REUTER Deputy <i>oil</i> ministers from six Gulf Arab" #> [50] "to discuss coordination of crude <i>oil</i> marketing the official Emirates news" #> [51] "by Gulf Cooperation Council GCC <i>oil</i> ministers to help each other" #> [52] "each other market their crude <i>oil</i> Four of the GCC states" #> [53] "OPEC accord to boost world <i>oil</i> prices and stabilize the market" #> [54] "recent fall in free market <i>oil</i> prices Nazer said Saudi Arabia" #> [55] "it will never sell its <i>oil</i> at prices below the pronounced" #> [56] "agreed to cut its total <i>oil</i> output ceiling by 7.25 pct" #> [57] "dollars a barrel Reuter Kuwait's <i>oil</i> minister said in a newspaper" #> [58] "the recent weakness in world <i>oil</i> prices Sheikh Ali al Khalifa" #> [59] "of crude daily bpd Crude <i>oil</i> prices fell sharply last week" #> [60] "sharply last week as international <i>oil</i> traders and analysts estimated the" #> [61] "was closed when a Cypriot <i>oil</i> tanker Seapride II ran aground" #> [62] "He said there was no <i>oil</i> spill but the ship is" #> [63] "the high tide After delivering <i>oil</i> to a refinery in Paulsboro" #> [64] "and future impact of low <i>oil</i> prices on the domestic oil" #> [65] "oil prices on the domestic <i>oil</i> industry U.S policy now is" #> [66] "called for new research for <i>oil</i> exploration and development techniques It" #> [67] "that such moves as increasing <i>oil</i> reserves and more exploration and" #> [68] "and future impact of low <i>oil</i> prices on the domestic oil" #> [69] "oil prices on the domestic <i>oil</i> industry U.S policy now is" #> [70] "called for new research for <i>oil</i> exploration and development techniques It" #> [71] "full economic benefits of cheap <i>oil</i> But the group did not" #> [72] "that such moves as increasing <i>oil</i> reserves and more exploration and" #> [73] "its posted prices for crude <i>oil</i> one to 1.50 dlrs a" #> [74] "West Coast grades of crude <i>oil</i> the company said Reuter The" #> [75] "April one NYMEX will allow <i>oil</i> traders that do not hold" #> [76] "This will change the way <i>oil</i> is transacted in the real" #> [77] "serve the industry because the <i>oil</i> market does not close when" #> [78] "CFTC spokeswoman Reuter Argentine crude <i>oil</i> production was down 10.8 pct"
as.character(oil, fmt = "<b>%s</b>")
#> [1] "its contract prices for crude <b><i>oil</i></b> by 1.50 dlrs a barrel" #> [2] "in the light of falling <b><i>oil</i></b> product prices and a weak" #> [3] "prices and a weak crude <b><i>oil</i></b> market a company spokeswoman said" #> [4] "in a line of U.S <b><i>oil</i></b> companies that have cut its" #> [5] "last two days citing weak <b><i>oil</i></b> markets Reuter OPEC may be" #> [6] "halt the current slide in <b><i>oil</i></b> prices oil industry analysts said" #> [7] "current slide in oil prices <b><i>oil</i></b> industry analysts said The movement" #> [8] "said The movement to higher <b><i>oil</i></b> prices was never to be" #> [9] "Research Associates CERA Analysts and <b><i>oil</i></b> industry sources said the problem" #> [10] "problem OPEC faces is excess <b><i>oil</i></b> supply in world oil markets" #> [11] "excess oil supply in world <b><i>oil</i></b> markets OPEC's problem is not" #> [12] "that way said Paul Mlotok <b><i>oil</i></b> analyst with Salomon Brothers Inc" #> [13] "to regain the initiative in <b><i>oil</i></b> prices But some other analysts" #> [14] "for one of the major <b><i>oil</i></b> companies who spoke on condition" #> [15] "winter demand to sell their <b><i>oil</i></b> but in late March and" #> [16] "that the demand for OPEC <b><i>oil</i></b> has been rising through the" #> [17] "production Demand for their OPEC <b><i>oil</i></b> is clearly above 15.8 mln" #> [18] "it will pay for crude <b><i>oil</i></b> 64 Canadian cts a barrel" #> [19] "Canada last changed its crude <b><i>oil</i></b> postings on Feb 19 Reuter" #> [20] "for all grades of crude <b><i>oil</i></b> one dlr a barrel effective" #> [21] "emergency OPEC meeting to review <b><i>oil</i></b> policies after recent weakness in" #> [22] "after recent weakness in world <b><i>oil</i></b> prices Sheikh Ali al Khalifa" #> [23] "Traders and analysts in international <b><i>oil</i></b> markets estimate OPEC is producing" #> [24] "a challenge to any international <b><i>oil</i></b> company that declared Kuwait sold" #> [25] "had guaranteed markets for its <b><i>oil</i></b> because of its local and" #> [26] "committee Referring to pressure by <b><i>oil</i></b> companies on OPEC members in" #> [27] "new report To counter falling <b><i>oil</i></b> revenues the government has launched" #> [28] "to boost exports outside the <b><i>oil</i></b> sector and attract new investment" #> [29] "year s fall in world <b><i>oil</i></b> prices which forced it to" #> [30] "industry Growth in the non <b><i>oil</i></b> sector is low because of" #> [31] "halting the current decline in <b><i>oil</i></b> prices Oil industry sources said" #> [32] "producers had had difficulty selling <b><i>oil</i></b> at official OPEC prices but" #> [33] "03 yesterday REUTER The Gulf <b><i>oil</i></b> state of Qatar recovering slightly" #> [34] "last year's decline in world <b><i>oil</i></b> prices announced its first budget" #> [35] "budget due to uncertainty surrounding <b><i>oil</i></b> revenues Sheikh Abdul Aziz said" #> [36] "was also no projection for <b><i>oil</i></b> revenue Qatar an OPEC member" #> [37] "expectations of positive signs regarding <b><i>oil</i></b> price trends foremost among them" #> [38] "OPEC accord to boost world <b><i>oil</i></b> prices and stabilise the market" #> [39] "recent fall in free market <b><i>oil</i></b> prices Nazer said Saudi Arabia" #> [40] "it will never sell its <b><i>oil</i></b> at prices below the pronounced" #> [41] "a year of turmoil on <b><i>oil</i></b> markets which saw prices slump" #> [42] "was shown clearly in the <b><i>oil</i></b> market He said contacts among" #> [43] "Traders and analysts in international <b><i>oil</i></b> markets estimate OPEC is producing" #> [44] "over producing REUTER Saudi crude <b><i>oil</i></b> output last month fell to" #> [45] "mln bpd in January Gulf <b><i>oil</i></b> sources said They said exports" #> [46] "December to back new official <b><i>oil</i></b> prices averaging 18 dlrs a" #> [47] "below Opec levels Saudi Arabian <b><i>oil</i></b> minister Hisham Nazer yesterday reiterated" #> [48] "export refineries They put crude <b><i>oil</i></b> exports through Yanbu at 100,000" #> [49] "200,000 bpd each REUTER Deputy <b><i>oil</i></b> ministers from six Gulf Arab" #> [50] "to discuss coordination of crude <b><i>oil</i></b> marketing the official Emirates news" #> [51] "by Gulf Cooperation Council GCC <b><i>oil</i></b> ministers to help each other" #> [52] "each other market their crude <b><i>oil</i></b> Four of the GCC states" #> [53] "OPEC accord to boost world <b><i>oil</i></b> prices and stabilize the market" #> [54] "recent fall in free market <b><i>oil</i></b> prices Nazer said Saudi Arabia" #> [55] "it will never sell its <b><i>oil</i></b> at prices below the pronounced" #> [56] "agreed to cut its total <b><i>oil</i></b> output ceiling by 7.25 pct" #> [57] "dollars a barrel Reuter Kuwait's <b><i>oil</i></b> minister said in a newspaper" #> [58] "the recent weakness in world <b><i>oil</i></b> prices Sheikh Ali al Khalifa" #> [59] "of crude daily bpd Crude <b><i>oil</i></b> prices fell sharply last week" #> [60] "sharply last week as international <b><i>oil</i></b> traders and analysts estimated the" #> [61] "was closed when a Cypriot <b><i>oil</i></b> tanker Seapride II ran aground" #> [62] "He said there was no <b><i>oil</i></b> spill but the ship is" #> [63] "the high tide After delivering <b><i>oil</i></b> to a refinery in Paulsboro" #> [64] "and future impact of low <b><i>oil</i></b> prices on the domestic oil" #> [65] "oil prices on the domestic <b><i>oil</i></b> industry U.S policy now is" #> [66] "called for new research for <b><i>oil</i></b> exploration and development techniques It" #> [67] "that such moves as increasing <b><i>oil</i></b> reserves and more exploration and" #> [68] "and future impact of low <b><i>oil</i></b> prices on the domestic oil" #> [69] "oil prices on the domestic <b><i>oil</i></b> industry U.S policy now is" #> [70] "called for new research for <b><i>oil</i></b> exploration and development techniques It" #> [71] "full economic benefits of cheap <b><i>oil</i></b> But the group did not" #> [72] "that such moves as increasing <b><i>oil</i></b> reserves and more exploration and" #> [73] "its posted prices for crude <b><i>oil</i></b> one to 1.50 dlrs a" #> [74] "West Coast grades of crude <b><i>oil</i></b> the company said Reuter The" #> [75] "April one NYMEX will allow <b><i>oil</i></b> traders that do not hold" #> [76] "This will change the way <b><i>oil</i></b> is transacted in the real" #> [77] "serve the industry because the <b><i>oil</i></b> market does not close when" #> [78] "CFTC spokeswoman Reuter Argentine crude <b><i>oil</i></b> production was down 10.8 pct"
# subsetting kwic objects oil <- corpus("REUTERS") %>% kwic(query = "oil") %>% subset(grepl("prices", right)) saudi_arabia <- corpus("REUTERS") %>% kwic(query = "Arabia") %>% subset(grepl("Saudi", left)) int_spd <- corpus("GERMAPARLMINI") %>% kwic(query = "Integration") %>% enrich(s_attribute = "party") %>% subset(grepl("SPD", party)) # turn kwic object into data.frame with html tags int <- corpus("GERMAPARLMINI") %>% kwic(query = "Integration") as.data.frame(int) # Without further metadata
#> left node #> 1 Es ist eine Frage der Integration #> 2 hilft weiter . Bildung , Integration #> 3 , die Bildung , die Integration #> 4 mit Nachdruck : Auch die Integration #> 5 wie wir im Bereich der Integration #> 6 ein Thema , das die Integration #> 7 Deutschland und Frankreich die europäische Integration #> 8 Auf ihm hat die europäische Integration #> 9 wird erwähnt , wie wichtig Integration #> 10 in Wohnquartieren einschließlich der besseren Integration #> 11 Migrationsbewegungen und zunehmender Vielfalt ist Integration #> 12 uns alle . Bei der Integration #> 13 aber zu kurz gegriffen , Integration #> 14 der Innenpolitik zu machen . Integration #> 15 wirklich nicht getan ; denn Integration #> 16 und vorurteilsfrei ist . Die Integration #> 17 Bildung und Ausbildung , für Integration #> 18 Rede . Wir brauchen verantwortungsbewusste Integration #> 19 der für das Gelingen der Integration #> 20 . Wir werden die europäische Integration #> 21 Das ist ein Schritt zur Integration #> 22 voranbringen und unsere Maßnahmen zur Integration #> 23 Wie schaffen wir bes- sere Integration #> right #> 1 der Menschen , die in #> 2 , solide Haushalte , generationengerechte #> 3 , die Arbeitsmarktpolitik und die #> 4 der Zuwanderer und ihrer Kinder #> 5 nachholen , was wir jahrzehntelang #> 6 betrifft . Junge Menschen , #> 7 in der Substanz - also #> 8 aufgebaut , und durch ihn #> 9 , sozialer Zusammenhalt und Ressourcenschutz #> 10 von Menschen mit Migrationshintergrund und #> 11 eine Schlüsselaufgabe für uns alle #> 12 von Zuwanderern haben wir bereits #> 13 nur im Zusammenhang mit Zuwanderern #> 14 in einem umfassenden Sinne bedeutet #> 15 umfasst viele Bereiche , von #> 16 von Menschen mit Migrationshintergrund ist #> 17 in den Beruf , für #> 18 . Das bedeutet , jeder #> 19 verantwortlich ist , muss sich #> 20 nicht als Bedrohung verstehen , #> 21 ; darin liegt für Kinder #> 22 von Jugendlichen durch Bildung und #> 23 in und durch Bildung ?
enrich(int, s_attributes = c("date", "speaker", "party")) %>% as.data.frame()
#> meta #> 1 2009-10-27<br/>Heinz Riesenhuber<br/>NA #> 2 2009-11-10<br/>Angela Dorothea Merkel<br/>CDU_CSU #> 3 2009-11-10<br/>Angela Dorothea Merkel<br/>CDU_CSU #> 4 2009-11-10<br/>Angela Dorothea Merkel<br/>CDU_CSU #> 5 2009-11-10<br/>Frank-Walter Steinmeier<br/>SPD #> 6 2009-11-10<br/>Volker Kauder<br/>CDU_CSU #> 7 2009-11-10<br/>Andreas Schockenhoff<br/>CDU_CSU #> 8 2009-11-10<br/>Andreas Schockenhoff<br/>CDU_CSU #> 9 2009-11-11<br/>Winfried Hermann<br/>B90_DIE_GRUENEN #> 10 2009-11-11<br/>Peter Götz<br/>CDU_CSU #> 11 2009-11-11<br/>Hermann Otto Solms<br/>NA #> 12 2009-11-11<br/>Hermann Otto Solms<br/>NA #> 13 2009-11-11<br/>Hermann Otto Solms<br/>NA #> 14 2009-11-11<br/>Hermann Otto Solms<br/>NA #> 15 2009-11-11<br/>Hartfrid Wolff<br/>FDP #> 16 2009-11-11<br/>Hartfrid Wolff<br/>FDP #> 17 2009-11-11<br/>Hartfrid Wolff<br/>FDP #> 18 2009-11-11<br/>Reinhard Grindel<br/>CDU_CSU #> 19 2009-11-11<br/>Reinhard Grindel<br/>CDU_CSU #> 20 2009-11-11<br/>Michael Grosse-Brömer<br/>CDU_CSU #> 21 2009-11-11<br/>Annette Schavan<br/>CDU_CSU #> 22 2009-11-11<br/>Annette Schavan<br/>CDU_CSU #> 23 2009-11-11<br/>Dagmar Ziegler<br/>SPD #> left node #> 1 Es ist eine Frage der Integration #> 2 hilft weiter . Bildung , Integration #> 3 , die Bildung , die Integration #> 4 mit Nachdruck : Auch die Integration #> 5 wie wir im Bereich der Integration #> 6 ein Thema , das die Integration #> 7 Deutschland und Frankreich die europäische Integration #> 8 Auf ihm hat die europäische Integration #> 9 wird erwähnt , wie wichtig Integration #> 10 in Wohnquartieren einschließlich der besseren Integration #> 11 Migrationsbewegungen und zunehmender Vielfalt ist Integration #> 12 uns alle . Bei der Integration #> 13 aber zu kurz gegriffen , Integration #> 14 der Innenpolitik zu machen . Integration #> 15 wirklich nicht getan ; denn Integration #> 16 und vorurteilsfrei ist . Die Integration #> 17 Bildung und Ausbildung , für Integration #> 18 Rede . Wir brauchen verantwortungsbewusste Integration #> 19 der für das Gelingen der Integration #> 20 . Wir werden die europäische Integration #> 21 Das ist ein Schritt zur Integration #> 22 voranbringen und unsere Maßnahmen zur Integration #> 23 Wie schaffen wir bes- sere Integration #> right #> 1 der Menschen , die in #> 2 , solide Haushalte , generationengerechte #> 3 , die Arbeitsmarktpolitik und die #> 4 der Zuwanderer und ihrer Kinder #> 5 nachholen , was wir jahrzehntelang #> 6 betrifft . Junge Menschen , #> 7 in der Substanz - also #> 8 aufgebaut , und durch ihn #> 9 , sozialer Zusammenhalt und Ressourcenschutz #> 10 von Menschen mit Migrationshintergrund und #> 11 eine Schlüsselaufgabe für uns alle #> 12 von Zuwanderern haben wir bereits #> 13 nur im Zusammenhang mit Zuwanderern #> 14 in einem umfassenden Sinne bedeutet #> 15 umfasst viele Bereiche , von #> 16 von Menschen mit Migrationshintergrund ist #> 17 in den Beruf , für #> 18 . Das bedeutet , jeder #> 19 verantwortlich ist , muss sich #> 20 nicht als Bedrohung verstehen , #> 21 ; darin liegt für Kinder #> 22 von Jugendlichen durch Bildung und #> 23 in und durch Bildung ?
# merge bundle of kwic objects into one kwic reuters <- corpus("REUTERS") queries <- c('"Saudi" "Arabia"', "oil", '"barrel.*"') comb <- lapply(queries, function(qu) kwic(reuters, query = qu)) %>% as.bundle() %>% merge() # enrich kwic object i <- corpus("GERMAPARLMINI") %>% kwic(query = "Integration") %>% enrich(s_attributes = c("date", "speaker", "party"))