knitr::opts_chunk$set(
  message = FALSE,
  warning = FALSE,
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

rdracor

Authors: Ivan Pozdniakov, Frank Fischer
License: GPL-3

The goal of rdracor is to provide an R interface for the DraCor API (DraCor: Drama Corpora Project). Website of the project: dracor.org.

Installation

Installation from CRAN:

install.packages("rdracor")

If you wish to install the current build of the next release you can do so using the following:

# install.packages("remotes")
remotes::install_github("dracor-org/rdracor")
library(rdracor)

Select DraCor API

DraCor API has several versions. By default, it utilizes the main branch:

get_dracor_api_url()

You can set DraCor URL API of your choice:

set_dracor_api_url("https://staging.dracor.org/api/v1")

General info on corpora

Retrieving general information about available corpora:

corpora <- get_dracor_meta()
summary(corpora)
plot(corpora)

Plays in the corpus

ger <- get_dracor(corpus = "ger")
summary(ger)

You can get all corpora at once:

all <- get_dracor()
summary(all)

Play metadata

With get_play_metadata() you can get miscellaneous data for a play:

get_play_metadata(play = "lessing-emilia-galotti", 
                  corpus = "ger",
                  full_metadata = FALSE) #use full_metadata = FALSE for faster download 

Play network

You can extract a co-occurence network (undirected weighted graph) for a specific play:

emilia <- get_net_cooccur_igraph(play = "lessing-emilia-galotti", corpus = "ger")
plot(emilia)

You can use the package {igraph} to work with this object as a graph:

library(igraph)
edge_density(emilia)
cohesion(emilia)

In addition, you can get a summary with network properties and gender distribution:

summary(emilia)

Similarly, you can use function get_net_relations_igraph() to build a network based on relationships data:

galotti_relations <- get_net_relations_igraph(play = "lessing-emilia-galotti",
                                               corpus = "ger")
plot(galotti_relations)
summary(galotti_relations)

Text of a play

You can get text of a play in different forms:

get_text_tei(play = "lessing-emilia-galotti", corpus = "ger")
text_galotti <- get_text_chr_spoken(play = "lessing-emilia-galotti",
                                     corpus = "ger")
head(text_galotti)
get_text_df(play = "lessing-emilia-galotti", corpus = "ger")

Changing DraCor API

If you want to use another version of DraCor API (e.g. staging or locally saved on your computer), you can use function set_dracor_api_url():

set_dracor_api_url("https://staging.dracor.org/api/v1")
get_dracor("u")

Information on the working API can be retrieved by dracor_api_info():

dracor_api_info()

Acknowledgments

The development of this research software was supported by Computational Literary Studies Infrastructure (CLS INFRA) through its Transnational Access Fellowship programme. CLS INFRA has received funding from the European Union’s Horizon 2020 research and innovation programme under grant agreement №101004984.



Pozdniakov/rdracor documentation built on Sept. 30, 2024, 6:18 p.m.