Spanish-language literature¶
SpanishLiterature(data_dir=DEFAULT_DATASET_DIR)
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 the country of the author (Juan Ruiz de Alarcón, born in Mexico, counts for Mexico): Spain (122), Argentina (10), Nicaragua (8), Mexico (3), Cuba (2), Uruguay (2), the Philippines (2), Peru (1). 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 and 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: what the editors and the transcribers added (title pages, tables of contents, introductions, notes, footnotes, advertisements) and the markup of the transcription are removed, while the prologues, dedications and notes of the authors 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 are named after the numbers of the books of Project Gutenberg.
The archive (19 MB) is kept in the repository of the library and downloaded once into the data directory.
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 |
Raises:
SourceTypeError- adata_dirthat is neither a string nor aPath.
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'}
Parameters¶
| Parameter | Type | Default | Description |
|---|---|---|---|
data_dir |
str / Path |
DEFAULT_DATASET_DIR |
Path to the dataset directory; texts in DEFAULT_DATA_DIR by default, 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¶
download(force=False) downloads the archive, verifies its SHA-256 checksum and extracts the files. A corrupted archive is downloaded again, missing files are extracted again; a repeated call downloads nothing.
| Parameter | Type | Default | Description |
|---|---|---|---|
force |
bool |
False |
Download the dataset even if it is already downloaded |
An archive that cannot be downloaded or fails the checksum twice raises DownloadError, an archive that cannot be extracted DataFileError.
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 with the commands to download it. The other methods check it themselves.
get_texts(genre=None, author=None, country=None, year_from=None, year_to=None, min_len=None, max_len=None, limit=None) 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 author or a country that is not a string, a year that is not an integer, an earliest year after the latest one, a length bound that is not an integer of at least one, a minimum length above the maximum one and a limit that is not a non-negative integer raise ParameterError.
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 with the same parameters 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 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: 61 of them have the accents of their time (á as a preposition, fué, dió), 87 the modern ones (among them a dozen texts that the transcribers of Project Gutenberg modernized) and two, La vuelta de Martín Fierro and Recuerdos de mi vida, a mixture; Galdós has texts of both kinds. 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.
Lines and paragraphs
The texts keep the line breaks of their transcriptions: the prose, the publicism and most of the plays wrap their lines inside the paragraphs, the poems give a line to a verse, and the paragraphs and the stanzas are separated by blank lines. The paragraphs of CohesionStats start after every line break by default: pass blank_lines=True for these texts, to the class or in the config of the component.
Editions and contents
Several works follow later editions revised by their authors (the Opera Omnia of Valle-Inclán, the complete works of Pereda, Palacio Valdés and Blasco Ibáñez, the much expanded sixth edition of Reglas y consejos sobre investigación científica), under the year 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 only published volume); the Entremeses are the eight of 1615, without the three of doubtful attribution, and 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.