ropensci/rperseus

Name: rperseus

Owner: rOpenSci

Description: Get primary texts from the Perseus Digital Library

Created: 2017-02-23 06:57:51.0

Updated: 2017-12-11 21:49:49.0

Pushed: 2017-11-28 21:49:19.0

Homepage: https://ropensci.github.io/rperseus/index.html

Size: 1224

Language: R

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

rperseus

Build Status codecov

Author: David Ranzolin

License: MIT

Goal

The goal of rperseus is to furnish classicists, textual critics, and R enthusiasts with texts from the Classical World. While the English translations of most texts are available through gutenbergr, rperseusreturns these works in their original language–Greek, Latin, and Hebrew.

Description

rperseus provides access to classical texts within the Perseus Digital Library's CapiTainS environment. A wealth of Greek, Latin, and Hebrew texts are available, from Homer to Cicero to Boetheius. The Perseus Digital Library includes English translations in some cases. The base API url is http://cts.perseids.org/api/cts.

Installation

rperseus is not on CRAN, but can be installed via:

ools::install_github("ropensci/rperseus")
Usage

See the vignette to get started.

To obtain a particular text, you must first know its full Uniform Resource Name (URN). URNs can be perused in the perseus_catalog, a data frame lazily loaded into the package. For example, say I want a copy of Virgil's Aeneid:

ary(dplyr)
ary(purrr)
ary(rperseus)

id_latin <- perseus_catalog %>% 
lter(group_name == "Virgil",
     label == "Aeneid",
     language == "lat") %>% 
ll(urn) %>% 
t_perseus_text()

You can also request an English translation for some texts:

id_english <- perseus_catalog %>% 
lter(group_name == "Virgil",
     label == "Aeneid",
     language == "eng") %>% 
ll(urn) %>% 
t_perseus_text()

Refer to the language variable in perseus_catalog for translation availability.

Excerpts

You can also specify excerpts:

leth <- get_perseus_text(urn = "urn:cts:ancJewLit:hebBible.ecclesiastes.leningrad-pntd", excerpt = "1.1-1.3")
leth$text
1] "????????? ???????? ????? ??????? ??????? ??????????????? : ?????? ????????? ?????? ???????? ?????? ????????? ??????? ?????? : ???? ?????????? ????????? ??????? ???????? ????????????? ??????? ??????????? :"
Parsing Excerpts

You can parse any Greek excerpt, returning a data frame with each word's part of speech, gender, case, mood, voice, tense, person, number, and degree.

e_excerpt("urn:cts:greekLit:tlg0031.tlg002.perseus-grc2", "5.1-5.2") %>% 
ad(7) %>% 
itr::kable()

| word | form | verse | part_of_speech | person | number | tense | mood | voice | gender | case | degree | |:——–|:———|:——|:—————–|:——-|:———|:——-|:———–|:——-|:———|:———–|:——-| | ??? | ??? | 5.1 | conjunction | NA | NA | NA | NA | NA | NA | NA | NA | | ??????? | ????? | 5.1 | verb | third | plural | aorist | indicative | active | NA | NA | NA | | ??? | ??? | 5.1 | preposition | NA | NA | NA | NA | NA | NA | NA | NA | | ? | ?? | 5.1 | article | NA | singular | NA | NA | NA | neuter | accusative | NA | | ????? | ????? | 5.1 | adverb | NA | NA | NA | NA | NA | NA | NA | NA | | ? | ??? | 5.1 | article | NA | singular | NA | NA | NA | feminine | genative | NA | | ??????? | ???????? | 5.1 | noun | NA | singular | NA | NA | NA | feminine | genative | NA |

tidyverse and tidytext

rperseus plays well with the tidyverse and tidytext. Here I obtain all of Plato's works that have English translations available:

ary(purrr)
o <- perseus_catalog %>% 
lter(group_name == "Plato",
     language == "eng") %>% 
ll(urn) %>% 
p_df(get_perseus_text)

And here's how to retrieve the Greek text from Sophocles' underrated Philoctetes before unleashing the tidytext toolkit:

ary(tidytext)

octetes <- perseus_catalog %>% 
lter(group_name == "Sophocles",
     label == "Philoctetes",
     language == "grc") %>% 
ll(urn) %>%
t_perseus_text()

octetes %>% 
nest_tokens(word, text) %>% 
unt(word, sort = TRUE) %>% 
ti_join(greek_stop_words)
oining, by = "word"
 A tibble: 3,514 x 2
         word     n
        <chr> <int>
1 ???????????   164
2  ??????????   141
3           ?   119
4          ??    74
5    ????????    56
6      ??????    47
7          ??    43
8       ?????    41
9          ??    40
0         ???    39
 ... with 3,504 more rows
Rendering Parallels

You can render small parallels with perseus_parallel:

le(label = c("Colossians", "1 Thessalonians", "Romans"),
          excerpt = c("1.4", "1.3", "8.35-8.39")) %>%
left_join(perseus_catalog) %>%
filter(language == "grc") %>%
select(urn, excerpt) %>%
pmap_df(get_perseus_text) %>%
perseus_parallel(words_per_row = 4)
oining, by = "label"

Meta

ropensci\_footer


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.