get_date_from_text: Extract Dates from Text

View source: R/get_date_from_text.R

get_date_from_textR Documentation

Extract Dates from Text

Description

This function extracts dates from text using specified patterns and formats.

Usage

get_date_from_text(texts, cb, type, links)

Arguments

texts

A tibble containing the text from which dates will be extracted. The tibble must have a column named "text" containing the text data.

cb

A character string indicating the source or context of the text (e.g., "boj", "fed").

type

A character string indicating the type of text (e.g., "minutes", "teala").

links

A character vector containing the links associated with the text.

Details

The function searches for specific date patterns in the provided text using regular expressions. It handles different formats and variations of dates commonly found in texts, such as "1st January 2022", "Jan 1, 2022", "01/01/22", etc. The extracted dates are then returned as start dates, end dates, and release dates, depending on the context and type of text.

Value

A list with three elements:

start_date

A vector of start dates extracted from the text.

end_date

A vector of end dates extracted from the text.

release_date

A vector of release dates extracted from the text.

Examples

## Not run: 
texts <- tibble::tibble(text = c("The minutes of the meeting held on January 15, 2022 are available now.",
           "Please refer to the report published on 01/20/22 for more information."))
cb <- "boj"
type <- "minutes"
links <- c("https://www.example.com/minutes_2022.html", "https://www.example.com/report_2022.html")
get_date_from_text(texts, cb, type, links)

## End(Not run)


martinbaumgaertner/cbtext documentation built on May 20, 2023, 9:54 p.m.