knitr::opts_chunk$set(widgetframe_self_contained = FALSE)
knitr::opts_chunk$set(widgetframe_isolate_widgets = TRUE)
knitr::opts_chunk$set(widgetframe_widgets_dir = 'widgets' ) 
required_packages <- c("vembedr", "htmltools", "devtools", "devtools", "widgetframe")
for (pkg in required_packages)
  if (!pkg %in% rownames(installed.packages())) install.packages(pkg)
if (!"annolite" %in% rownames(installed.packages()))
  devtools::install_github("PolMine/annolite")

Concordances and KWIC: Foundations {.smaller}

Required Installations and Initialization {.smaller}

if (packageVersion("polmineR") < as.package_version("0.7.9.9010"))
  devtools::install_github("PolMine/polmineR", ref = "dev")
library(polmineR)
use("UNGA")

kwic() method: First steps {.smaller}

options("polmineR.pagelength" = 4L)
kwic("UNGA", query = "immigration")



vembedr::embed_youtube("F4UkFI0aolI", height = 400, width = 600)

Partitions and Concordances {.smaller}

options("polmineR.pagelength" = 3L)
unga_2005 <- partition("UNGA", year = 2005)
kwic(unga_2005, query = "immigration")

Using the CQP syntax {.smaller}

options("polmineR.pagelength" = 5L)
kwic(unga_2005, query = '[pos = "J.*"] "immigration"', cqp = TRUE)

KWIC: Adjusting the word context I {.smaller}

options("polmineR.pagelength" = 4L)
kwic("UNGA", query = "border", left = 15, right = 15)

KWIC: Adjusting the word context II {.smaller}

getOption("polmineR.left")
getOption("polmineR.right")
options(polmineR.left = 10)
options(polmineR.right = 10)
options("polmineR.pagelength" = 5L)
options("polmineR.left" = 5L)
options("polmineR.right" = 5L)

KWIC: Showing Metadata {.smaller}

kwic(unga_2005, query = "immigration", s_attributes = "state_organization", verbose = FALSE)

KWIC: Showing Metadata (Continued) {.smaller}

options("polmineR.pagelength" = 3L)
kwic(unga_2005, query = "immigration", s_attributes = c("state_organization", "date"), verbose = FALSE)
s_attributes(unga_2005)

Highlighting Terms in Word Context {.smaller}

K <- kwic(
  "UNGA", query = "Islam", s_attributes = c("state_organization", "date"),
  positivelist = "terror"
)
K <- highlight(K, yellow = "terror")
K

From concordances to full text view

K <- kwic(unga_2005, query = "immigration")
read(K, i = 1)

Full Text View

i <- 1L
metadata <- c("speaker", "date", "state_organization")
K <- kwic(unga_2005, query = "immigration", s_attributes = metadata)
P <- partition(
  get_corpus(K),
  def = lapply(setNames(metadata, metadata), function(x) K@stat[[x]][i]),
  type = "plpr"
)
data <- annolite::as.fulltextdata(P, headline = "Cornelie Sonntag-Wolgast (2005-01-21)")
data$annotations <- data.frame(
  text = c("", "", ""),
  code = c("yellow", "lightgreen", "yellow"),
  annotation = c("", "", ""),
  id_left = c(
    min(K@cpos[hit_no == i][direction == -1][["cpos"]]),
    min(K@cpos[hit_no == i][direction == 0][["cpos"]]),
    min(K@cpos[hit_no == i][direction == 1][["cpos"]])
    ),
  id_right = c(
    max(K@cpos[hit_no == i][direction == -1][["cpos"]]),
    min(K@cpos[hit_no == i][direction == 0][["cpos"]]),
    max(K@cpos[hit_no == i][direction == 1][["cpos"]])
    )
)
W <- annolite::fulltext(data, dialog = NULL, box = TRUE, width = 1000, height = 400)
Y <- widgetframe::frameWidget(W)
Y

Prospects: Concordances in the Research Process {.smaller}

References



PolMine/UCSSR documentation built on June 13, 2022, 10:23 p.m.