Spanish-language literature¶
ests.datasets.SpanishLiterature
Description¶
A collection of Spanish-language literature in the public domain: 150 works by 33 authors from Spain, Latin America and the Philippines, from Cervantes to the 1920s, 65 million characters (about 11 million words) in four genres:
| Genre | Key | Authors | Works |
|---|---|---|---|
| Prose | prose |
Pérez Galdós (21), Blasco Ibáñez (15), Palacio Valdés (13), Pardo Bazán (13), Pereda (8), Unamuno (6), Valera (6), Valle-Inclán (5), Clarín (3), Payró (3), Alarcón (2), Cervantes (2), Martí (2), Rizal (2), Darío, Larra, Lugones, Palma, Quevedo, Quiroga | 107 |
| Poetry | poems |
Darío (5), Hernández (2), Machado, Rosalía de Castro, Zorrilla | 10 |
| Drama | drama |
Valle-Inclán (4), Arniches (3), Ruiz de Alarcón (3), Lope de Vega (2), Cervantes, Dicenta, Moratín, Zorrilla | 16 |
| Publicism | publicism |
Unamuno (3), Darío (2), Ingenieros (2), Ramón y Cajal (2), Alarcón, Blasco Ibáñez, Larra, Lugones, Rodó, Sarmiento, Valera, Zorrilla | 17 |
By country: Spain (122), Argentina (10), Nicaragua (8), Mexico (3), Cuba (2), Uruguay (2), the Philippines (2), Peru (1); the country is that of the author, so Juan Ruiz de Alarcón, born in Mexico, counts for Mexico. Every work is in the public domain both in Spain, where the author died before 1946, and in the United States, where it was published before 1931. The collection suits authorship attribution, the comparison of genres, of periods and of the Spanish of Spain and of America.
The texts are the transcriptions of Project Gutenberg, cut to the text of the author: the title pages, the notes of the transcribers, the lists of other works and the advertisements, the tables of contents, the introductions, prologues and notes of the editors, the errata and the footnotes are removed, as well as the markup of the transcriptions (the underscores of italics, the images, the numbers of stanzas). The prologues, dedications and notes of the authors themselves stay. Works in several volumes are joined in one text. The years are those of the first publication (1605-1615 for the two parts of Don Quijote); the files of the collection are named after the numbers of the books of Project Gutenberg.
The archive (19 MB) is kept in the repository of the library, is downloaded once into the data directory, verified against its SHA-256 checksum and extracted; the texts are read one at a time.
The 150 works
| Author | Work | Genre | Years | Country |
|---|---|---|---|---|
| Pedro Antonio de Alarcón | El clavo | prose |
1853 | España |
| Pedro Antonio de Alarcón | El niño de la bola | prose |
1880 | España |
| Vicente Blasco Ibáñez | Arroz y tartana | prose |
1894 | España |
| Vicente Blasco Ibáñez | Flor de mayo | prose |
1895 | España |
| Vicente Blasco Ibáñez | La barraca | prose |
1898 | España |
| Vicente Blasco Ibáñez | Entre naranjos | prose |
1900 | España |
| Vicente Blasco Ibáñez | La catedral | prose |
1903 | España |
| Vicente Blasco Ibáñez | El intruso | prose |
1904 | España |
| Vicente Blasco Ibáñez | La bodega | prose |
1905 | España |
| Vicente Blasco Ibáñez | La horda | prose |
1905 | España |
| Vicente Blasco Ibáñez | La maja desnuda | prose |
1906 | España |
| Vicente Blasco Ibáñez | Sangre y arena | prose |
1908 | España |
| Vicente Blasco Ibáñez | Los muertos mandan | prose |
1909 | España |
| Vicente Blasco Ibáñez | Los argonautas | prose |
1914 | España |
| Vicente Blasco Ibáñez | Los cuatro jinetes del Apocalipsis | prose |
1916 | España |
| Vicente Blasco Ibáñez | Mare nostrum | prose |
1918 | España |
| Vicente Blasco Ibáñez | Los enemigos de la mujer | prose |
1919 | España |
| Miguel de Cervantes | Don Quijote de la Mancha | prose |
1605-1615 | España |
| Miguel de Cervantes | Novelas ejemplares | prose |
1613 | España |
| Leopoldo Alas «Clarín» | La Regenta | prose |
1884-1885 | España |
| Leopoldo Alas «Clarín» | Su único hijo | prose |
1890 | España |
| Leopoldo Alas «Clarín» | El Señor y lo demás, son cuentos | prose |
1893 | España |
| Rubén Darío | Azul... | prose |
1888 | Nicaragua |
| Benito Pérez Galdós | La Fontana de Oro | prose |
1870 | España |
| Benito Pérez Galdós | Bailén | prose |
1873 | España |
| Benito Pérez Galdós | Trafalgar | prose |
1873 | España |
| Benito Pérez Galdós | Cádiz | prose |
1874 | España |
| Benito Pérez Galdós | Zaragoza | prose |
1874 | España |
| Benito Pérez Galdós | Gloria | prose |
1876-1877 | España |
| Benito Pérez Galdós | Marianela | prose |
1878 | España |
| Benito Pérez Galdós | La familia de León Roch | prose |
1878-1879 | España |
| Benito Pérez Galdós | La desheredada | prose |
1881 | España |
| Benito Pérez Galdós | El amigo Manso | prose |
1882 | España |
| Benito Pérez Galdós | La de Bringas | prose |
1884 | España |
| Benito Pérez Galdós | Tormento | prose |
1884 | España |
| Benito Pérez Galdós | Fortunata y Jacinta | prose |
1887 | España |
| Benito Pérez Galdós | Miau | prose |
1888 | España |
| Benito Pérez Galdós | Torquemada en la hoguera | prose |
1889 | España |
| Benito Pérez Galdós | Realidad | prose |
1889 | España |
| Benito Pérez Galdós | La incógnita | prose |
1889 | España |
| Benito Pérez Galdós | Torquemada en la cruz | prose |
1893 | España |
| Benito Pérez Galdós | Torquemada en el purgatorio | prose |
1894 | España |
| Benito Pérez Galdós | Torquemada y San Pedro | prose |
1895 | España |
| Benito Pérez Galdós | Misericordia | prose |
1897 | España |
| Mariano José de Larra | El doncel de don Enrique el Doliente | prose |
1834 | España |
| Leopoldo Lugones | Las fuerzas extrañas | prose |
1906 | Argentina |
| José Martí | Amistad funesta | prose |
1885 | Cuba |
| José Martí | La Edad de Oro | prose |
1889 | Cuba |
| Armando Palacio Valdés | El señorito Octavio | prose |
1881 | España |
| Armando Palacio Valdés | Marta y María | prose |
1883 | España |
| Armando Palacio Valdés | El idilio de un enfermo | prose |
1884 | España |
| Armando Palacio Valdés | Riverita | prose |
1886 | España |
| Armando Palacio Valdés | Maximina | prose |
1887 | España |
| Armando Palacio Valdés | El cuarto poder | prose |
1888 | España |
| Armando Palacio Valdés | La hermana San Sulpicio | prose |
1889 | España |
| Armando Palacio Valdés | La espuma | prose |
1890 | España |
| Armando Palacio Valdés | La fe | prose |
1892 | España |
| Armando Palacio Valdés | El maestrante | prose |
1893 | España |
| Armando Palacio Valdés | La alegría del capitán Ribot | prose |
1899 | España |
| Armando Palacio Valdés | La aldea perdida | prose |
1903 | España |
| Armando Palacio Valdés | Tristán o el pesimismo | prose |
1906 | España |
| Ricardo Palma | Tradiciones peruanas | prose |
1872-1910 | Perú |
| Emilia Pardo Bazán | Un viaje de novios | prose |
1881 | España |
| Emilia Pardo Bazán | La Tribuna | prose |
1883 | España |
| Emilia Pardo Bazán | El cisne de Vilamorta | prose |
1885 | España |
| Emilia Pardo Bazán | Los pazos de Ulloa | prose |
1886 | España |
| Emilia Pardo Bazán | La madre naturaleza | prose |
1887 | España |
| Emilia Pardo Bazán | Insolación y Morriña | prose |
1889 | España |
| Emilia Pardo Bazán | Una cristiana | prose |
1890 | España |
| Emilia Pardo Bazán | La prueba | prose |
1890 | España |
| Emilia Pardo Bazán | La piedra angular | prose |
1891 | España |
| Emilia Pardo Bazán | Cuentos de amor | prose |
1898 | España |
| Emilia Pardo Bazán | La quimera | prose |
1905 | España |
| Emilia Pardo Bazán | La sirena negra | prose |
1908 | España |
| Emilia Pardo Bazán | Dulce dueño | prose |
1911 | España |
| Roberto J. Payró | El casamiento de Laucha | prose |
1906 | Argentina |
| Roberto J. Payró | Pago Chico | prose |
1908 | Argentina |
| Roberto J. Payró | Divertidas aventuras del nieto de Juan Moreira | prose |
1910 | Argentina |
| José María de Pereda | Escenas montañesas | prose |
1864 | España |
| José María de Pereda | Los hombres de pro | prose |
1872 | España |
| José María de Pereda | De tal palo, tal astilla | prose |
1880 | España |
| José María de Pereda | El sabor de la tierruca | prose |
1882 | España |
| José María de Pereda | Pedro Sánchez | prose |
1883 | España |
| José María de Pereda | Sotileza | prose |
1885 | España |
| José María de Pereda | La puchera | prose |
1889 | España |
| José María de Pereda | Peñas arriba | prose |
1895 | España |
| Francisco de Quevedo | Historia de la vida del Buscón | prose |
1626 | España |
| Horacio Quiroga | Cuentos de amor de locura y de muerte | prose |
1917 | Uruguay |
| José Rizal | Noli me tángere | prose |
1887 | Filipinas |
| José Rizal | El filibusterismo | prose |
1891 | Filipinas |
| Miguel de Unamuno | Amor y pedagogía | prose |
1902 | España |
| Miguel de Unamuno | El espejo de la muerte | prose |
1913 | España |
| Miguel de Unamuno | Niebla | prose |
1914 | España |
| Miguel de Unamuno | Abel Sánchez | prose |
1917 | España |
| Miguel de Unamuno | Tres novelas ejemplares y un prólogo | prose |
1920 | España |
| Miguel de Unamuno | La tía Tula | prose |
1921 | España |
| Juan Valera | Pepita Jiménez | prose |
1874 | España |
| Juan Valera | Las ilusiones del doctor Faustino | prose |
1875 | España |
| Juan Valera | El comendador Mendoza | prose |
1877 | España |
| Juan Valera | Doña Luz | prose |
1879 | España |
| Juan Valera | Juanita la Larga | prose |
1895 | España |
| Juan Valera | Genio y figura | prose |
1897 | España |
| Ramón del Valle-Inclán | Sonata de otoño. Sonata de invierno | prose |
1902-1905 | España |
| Ramón del Valle-Inclán | Sonata de estío | prose |
1903 | España |
| Ramón del Valle-Inclán | Sonata de primavera | prose |
1904 | España |
| Ramón del Valle-Inclán | La media noche | prose |
1917 | España |
| Ramón del Valle-Inclán | Tirano Banderas | prose |
1926 | España |
| Rubén Darío | Prosas profanas | poems |
1896 | Nicaragua |
| Rubén Darío | Cantos de vida y esperanza | poems |
1905 | Nicaragua |
| Rubén Darío | El canto errante | poems |
1907 | Nicaragua |
| Rubén Darío | Poema del otoño y otros poemas | poems |
1910 | Nicaragua |
| Rubén Darío | Canto a la Argentina y otros poemas | poems |
1914 | Nicaragua |
| José Hernández | El gaucho Martín Fierro | poems |
1872 | Argentina |
| José Hernández | La vuelta de Martín Fierro | poems |
1879 | Argentina |
| Antonio Machado | Poesías completas | poems |
1917 | España |
| Rosalía de Castro | En las orillas del Sar | poems |
1884 | España |
| José Zorrilla | Granada. Poema oriental | poems |
1852 | España |
| Carlos Arniches | La señorita de Trevélez | drama |
1916 | España |
| Carlos Arniches | Los caciques | drama |
1920 | España |
| Carlos Arniches | Es mi hombre | drama |
1921 | España |
| Miguel de Cervantes | Entremeses | drama |
1615 | España |
| Joaquín Dicenta | Juan José | drama |
1895 | España |
| Lope de Vega | Fuenteovejuna | drama |
1619 | España |
| Lope de Vega | El castigo sin venganza | drama |
1634 | España |
| Leandro Fernández de Moratín | El sí de las niñas | drama |
1806 | España |
| Juan Ruiz de Alarcón | Los favores del mundo | drama |
1628 | México |
| Juan Ruiz de Alarcón | Las paredes oyen | drama |
1628 | México |
| Juan Ruiz de Alarcón | La verdad sospechosa | drama |
1634 | México |
| Ramón del Valle-Inclán | El marqués de Bradomín | drama |
1907 | España |
| Ramón del Valle-Inclán | Romance de lobos | drama |
1908 | España |
| Ramón del Valle-Inclán | Luces de bohemia | drama |
1920-1924 | España |
| Ramón del Valle-Inclán | Divinas palabras | drama |
1920 | España |
| José Zorrilla | Traidor, inconfeso y mártir | drama |
1849 | España |
| Pedro Antonio de Alarcón | Viajes por España | publicism |
1883 | España |
| Vicente Blasco Ibáñez | Oriente | publicism |
1907 | España |
| Rubén Darío | Los raros | publicism |
1896 | Nicaragua |
| Rubén Darío | España contemporánea | publicism |
1901 | Nicaragua |
| José Ingenieros | La simulación en la lucha por la vida | publicism |
1903 | Argentina |
| José Ingenieros | El hombre mediocre | publicism |
1913 | Argentina |
| Mariano José de Larra | Fígaro. Artículos selectos | publicism |
1832-1837 | España |
| Leopoldo Lugones | El payador | publicism |
1916 | Argentina |
| Santiago Ramón y Cajal | Reglas y consejos sobre investigación científica | publicism |
1897 | España |
| Santiago Ramón y Cajal | Recuerdos de mi vida | publicism |
1901-1917 | España |
| José Enrique Rodó | Ariel | publicism |
1900 | Uruguay |
| Domingo Faustino Sarmiento | Facundo | publicism |
1845 | Argentina |
| Miguel de Unamuno | Vida de Don Quijote y Sancho | publicism |
1905 | España |
| Miguel de Unamuno | Del sentimiento trágico de la vida | publicism |
1913 | España |
| Miguel de Unamuno | Andanzas y visiones españolas | publicism |
1922 | España |
| Juan Valera | Cartas americanas | publicism |
1889 | España |
| José Zorrilla | Recuerdos del tiempo viejo I | publicism |
1880 | España |
Parameters¶
| Parameter | Type | Default | Description |
|---|---|---|---|
data_dir |
str/Path | DEFAULT_DATA_DIR.joinpath("texts") |
Path to the dataset directory; the data directory is described in Installation |
Attributes¶
| Attribute | Type | Description |
|---|---|---|
genres |
tuple[str] | Tuple of genres: prose, poems, drama, publicism |
authors |
dict[str, str] | Names of the authors by the names of their folders |
name |
str | Name of the dataset, spanish_literature |
meta |
dict[str, str] | Reference information: the source, the description, the author and the licence |
info |
dict[str, str] | The name and the reference information in one dictionary |
data_dir |
Path | Absolute path to the dataset directory |
filepath |
str | Path to the archive of the dataset, None before the download |
The dataset iterates over its records as get_records() without filters: for record in sl goes over the works one at a time.
Methods¶
check_data¶
Checks that the list of works and the file of every work are in place and returns True; a dataset that is not downloaded or misses a file raises DatasetNotFoundError. The other methods check it themselves.
download¶
Downloads the archive with checksum verification and extracts the files. A corrupted or replaced archive is removed and downloaded again in the same call; if the archive is there but some files are missing, it is extracted again. A repeated call downloads nothing.
| Parameter | Type | Default | Description |
|---|---|---|---|
force |
bool | False |
Download the dataset even if it is already downloaded |
Example
from ests.datasets import SpanishLiterature
sl = SpanishLiterature()
sl.download()
sl.info
# {'name': 'spanish_literature',
# 'url': 'https://www.gutenberg.org',
# 'description': 'Spanish-language literature in the public domain',
# 'author': 'Shkarin S.S.',
# 'license': 'Public domain'}
get_texts¶
Extracts the texts (without headers) from the dataset.
| Parameter | Type | Default | Description |
|---|---|---|---|
genre |
str | None |
Genre: prose, poems, drama or publicism |
author |
str | None |
Author: a substring of the name, regardless of case and accents |
country |
str | None |
Country: a substring of the name in Spanish, regardless of case and accents |
year_from |
int | None |
Earliest year of the first publication |
year_to |
int | None |
Latest year of the first publication |
min_len |
int | None |
Minimum text length (in characters) |
max_len |
int | None |
Maximum text length (in characters) |
limit |
int | None |
Number of texts |
The filters are combined; author="galdos" finds Benito Pérez Galdós, country="mexico" finds México. An unknown genre, an earliest year after the latest one, a length below one, a minimum length above the maximum one and a negative limit raise ParameterError.
Example
from ests.datasets import SpanishLiterature
sl = SpanishLiterature()
for text in sl.get_texts(genre="poems", author="Rosalía", limit=1):
print(text[:107])
# Aunque no alcancen gloria,
# Pensé escribiendo libro tan pequeño,
# Son fáciles y breves mis canciones,
get_records¶
Extracts the records (with headers) from the dataset. Record fields: genre - genre, author - author, title - title, year_from and year_to - the years of the first publication, country - the country of the author in Spanish, text - text, file - path to the file. The records go by genre in the order of genres, within a genre by the folder of the author and by year.
The parameters are the same as for get_texts.
Example
from ests.datasets import SpanishLiterature
sl = SpanishLiterature()
# The plays of the twentieth century
for record in sl.get_records(genre="drama", year_from=1900):
print(record["title"], record["year_from"], record["author"])
# La señorita de Trevélez 1916 Carlos Arniches
# Los caciques 1920 Carlos Arniches
# Es mi hombre 1921 Carlos Arniches
# El marqués de Bradomín 1907 Ramón del Valle-Inclán
# Romance de lobos 1908 Ramón del Valle-Inclán
# Luces de bohemia 1920 Ramón del Valle-Inclán
# Divinas palabras 1920 Ramón del Valle-Inclán
The spelling follows the edition
The texts keep the spelling of the transcribed editions. 62 of them have the accents of their time (á as a preposition, fué, dió), 87 have the modern ones: the editions printed after the reforms of the Academy, and a dozen texts that the transcribers of Project Gutenberg modernized to the rules of 2010 (among them El castigo sin venganza, Las paredes oyen, Tirano Banderas, Luces de bohemia, Los caciques and Es mi hombre). Three novels come from editions of 1978-1982 with modern spelling (Arroz y tartana, La catedral, Juanita la Larga). Galdós has 12 texts of the first kind and 9 of the second. Since á and a are different words for a frequency list, stylometry over the most frequent words can separate the texts by their edition rather than by their author: remove the accent of the monosyllables (á, é, ó, ú, fué, dió, vió) before such a comparison. Abel Sánchez lacks most of the opening ¿ and ¡, as its edition does.
Editions and contents
Several works follow editions revised by their authors: the Opera Omnia of Valle-Inclán (1913-1924), the complete works of Pereda, Palacio Valdés and Blasco Ibáñez, the sixth edition of Reglas y consejos sobre investigación científica (1923), much expanded from the speech of 1897; the years stay those of the first publication. Some records are selections or single volumes: Tradiciones peruanas (27 tradiciones), Recuerdos del tiempo viejo I (the first of three volumes), El payador (the first and only published volume); the Entremeses are the eight of the collection of 1615, without the three of doubtful attribution. Novelas ejemplares go without La tía fingida. Two records hold two works each, as their titles say: Insolación y Morriña and Sonata de otoño. Sonata de invierno. In some plays of the Golden Age the square brackets of the editors remain around the stage directions and the names they added.