-
Notifications
You must be signed in to change notification settings - Fork 3
/
README.Rmd
151 lines (105 loc) · 4.61 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-"
)
```
## rperseus
***
[![Build Status](https://travis-ci.org/ropensci/rperseus.svg?branch=master)](https://travis-ci.org/ropensci/rperseus)
[![codecov](https://codecov.io/gh/ropensci/rperseus/branch/master/graph/badge.svg)](https://codecov.io/gh/ropensci/rperseus)
[![](https://badges.ropensci.org/145_status.svg)](https://github.com/ropensci/onboarding/issues/145)
![](http://www.infobiblio.es/wp-content/uploads/2015/06/perseus-logo.png)
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`, `rperseus`returns these works in their original language--Greek, Latin, and Hebrew.
## Description
`rperseus` provides access to classical texts within the [Perseus Digital Library's](http://www.perseus.tufts.edu/hopper/) 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:
```{r eval = FALSE}
devtools::install_github("ropensci/rperseus")
```
## Usage
[See the vignette to get started.](https://daranzolin.github.io/rperseus//articles/rperseus-vignette.html)
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*:
```{r warning = FALSE, message=FALSE}
library(dplyr)
library(purrr)
library(rperseus)
aeneid_latin <- perseus_catalog %>%
filter(group_name == "Virgil",
label == "Aeneid",
language == "lat") %>%
pull(urn) %>%
get_perseus_text()
```
You can also request an English translation for some texts:
```{r eval = FALSE}
aeneid_english <- perseus_catalog %>%
filter(group_name == "Virgil",
label == "Aeneid",
language == "eng") %>%
pull(urn) %>%
get_perseus_text()
```
Refer to the language variable in `perseus_catalog` for translation availability.
## Excerpts
You can also specify excerpts:
```{r}
qoheleth <- get_perseus_text(urn = "urn:cts:ancJewLit:hebBible.ecclesiastes.leningrad-pntd", excerpt = "1.1-1.3")
qoheleth$text
```
## 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.
```{r}
parse_excerpt("urn:cts:greekLit:tlg0031.tlg002.perseus-grc2", "5.1-5.2") %>%
head(7) %>%
knitr::kable()
```
## tidyverse and tidytext
`rperseus` plays well with the `tidyverse` and `tidytext`. Here I obtain all of Plato's works that have English translations available:
```{r eval = FALSE, warning = FALSE}
library(purrr)
plato <- perseus_catalog %>%
filter(group_name == "Plato",
language == "eng") %>%
pull(urn) %>%
map_df(get_perseus_text)
```
And here's how to retrieve the Greek text from Sophocles' underrated *Philoctetes* before unleashing the `tidytext` toolkit:
```{r warning = FALSE}
library(tidytext)
philoctetes <- perseus_catalog %>%
filter(group_name == "Sophocles",
label == "Philoctetes",
language == "grc") %>%
pull(urn) %>%
get_perseus_text()
philoctetes %>%
unnest_tokens(word, text) %>%
count(word, sort = TRUE) %>%
anti_join(greek_stop_words)
```
## Rendering Parallels
You can render small parallels with `perseus_parallel`:
```{r,fig.width=8, fig.height=6}
tibble(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)
```
## Meta
* [Report bugs or issues here.](https://github.com/daranzolin/rperseus/issues)
* If you'd like to contribute to the development of `rperseus`, first get acquainted with the Perseus Digital Library, fork the repo, and send a pull request.
* This project is released with a [Contributor Code of Conduct.](https://github.com/daranzolin/rperseus/blob/master/CONDUCT.md) By participating in this project, you agree to abide by its terms.
[![ropensci_footer](https://ropensci.org/public_images/ropensci_footer.png)](https://ropensci.org)