Title: | 'PoetryDB' API Wrapper |
---|---|
Description: | Wrapper for the 'PoetryDB' API <http://poetrydb.org> that allows for interaction and data extraction from the database in an R interface. The 'PoetryDB' API is a database of poetry and poets implemented with 'MongoDB' to enable developers and poets to easily access one of the most comprehensive poetry databases currently available. |
Authors: | Aaron Schlegel |
Maintainer: | Aaron Schlegel <[email protected]> |
License: | GPL-2 |
Version: | 1.1.0 |
Built: | 2025-01-19 02:44:26 UTC |
Source: | https://github.com/aschleg/rpoet |
Primary function for interfacing with the PoetryDB API.
get.poetry(input_term, search_term = NULL, output = NULL, output_format = NULL, search_type = NULL)
get.poetry(input_term, search_term = NULL, output = NULL, output_format = NULL, search_type = NULL)
input_term |
The desired input term for searching PoetryDB. Must be one of or any combination of 'author', 'title', 'lines', or 'linecount'. |
search_term |
Relates to the 'input_term'. The search term should be relevant to the given input term. If multiple 'input_term' parameters are given, each must have a corresponding 'search_term'. |
output |
Can be any or a combination of the input terms 'author', 'title', 'lines', 'linecount'. If NULL, all the data returned from PoetryDB by the search will be returned. The output can also be a combination of the terms, for example, an output of 'author,title,lines,linecount', will return the same result as if the parameter is set to NULL. An output of 'title,lines', will return the poem's title and text. |
output_format |
If NULL or 'json', the results are returned in JSON format (the PoetryDB API default). If 'text', the results are returned as a parsed string using the [stringr](https://CRAN.R-project.org/package=stringr) package. |
search_type |
If NULL (default), the search attempts to match any part of the ‘input_term'. If ’abs', the search will attempt to find an exact match when searching for the 'input_term'. |
Search result returned by the PoetryDB API interface in either a JSON-like object or text (depending on what is passed in the 'output_format').
# Get all of William Shakespeare's poetry by title and lines shakespeare <- get.poetry('author', 'William Shakespeare', 'title,lines') # Get all ten books of Paradise Lost written by John Milton by linecount and lines paradise_lost <- get.poetry('title', 'Paradise Lost', 'linecount,lines')
# Get all of William Shakespeare's poetry by title and lines shakespeare <- get.poetry('author', 'William Shakespeare', 'title,lines') # Get all ten books of Paradise Lost written by John Milton by linecount and lines paradise_lost <- get.poetry('title', 'Paradise Lost', 'linecount,lines')