An R toolkit for building text corpora and searching them. Collect URLs and provenance from RSS and Atom feeds, Wikipedia and its citations, or supply existing URLs. No custom object classes, just plain data frames from start to finish. Covers the full arc from URL to retrieved passage through a consistent four-step API: Fetch, Read, Process, Search. Traditional tools (KWIC, BM25, dictionary matching) sit alongside modern ones (semantic search, LLM-ready chunking), all compatible with the native R pipe ('|>').
textpress is an R toolkit for building text corpora and searching them -- no custom object classes, just plain data frames from start to finish. It collects URLs from durable sources -- RSS and Atom feeds, Wikipedia and its citations, or URLs you already have -- then reads, processes, and searches the resulting text through a consistent four-step API: Fetch, Read, Process, Search.
From CRAN:
install.packages("textpress")
Development version:
remotes::install_github("jaytimm/textpress")
Select a small set of known publishers, retrieve their recent feed entries,
then read the linked pages. read_urls() retains the RSS discovery metadata.
feeds <- textpress::rss_local_rags |>
subset(state_abbr == "NM") |>
head(2)
articles <- textpress::fetch_rss(feeds$url)
corpus <- textpress::read_urls(articles)
corpus$text
corpus$meta
There are three ways into the same pipeline:
| Starting point | Entry point | Best for |
|---|---|---|
| Known publishers | rss_politics or rss_local_rags -> fetch_rss() |
Recent, source-led collections |
| A topic | fetch_wiki_urls() -> fetch_wiki_refs() |
Topic- and citation-led discovery |
| Existing URLs | read_urls() directly |
Curated or externally collected corpora |
Each route converges on read_urls() -> nlp_*() -> search_*().
textpress APIConventions: corpus is a data frame with a text column plus identifier column(s) passed to by (default doc_id). All outputs are plain data frames or data.tables; pipe-friendly.
fetch_*)Collect URLs and provenance from stable sources -- not full article text. textpress
does not provide general-purpose live web search. Pass fetch results to
read_urls() to retrieve their content.
fetch_rss(feed_url) -- Retrieve recent entries from RSS and Atom feeds; bundled catalogs are available as rss_politics and rss_local_rags.fetch_wiki_urls(query, limit) -- Wikipedia article URLs matching a search phrase.fetch_wiki_refs(url, n) -- External citation URLs from a Wikipedia article's References section.read_*)Scrape and parse URLs into a structured corpus.
read_urls(x, ...) -- URL vector or fetch-result table → list(text, meta). Passing a table preserves its discovery metadata and doc_id. text is one row per node; meta is one row per URL.nlp_*)Prepare text for search or indexing.
nlp_split_paragraphs() -- Break documents into structural blocks.nlp_split_sentences() -- Segment blocks into individual sentences.nlp_tokenize_text() -- Normalize text into a clean token stream.nlp_index_tokens() -- Build a weighted BM25 index for ranked retrieval.nlp_roll_chunks() -- Roll sentences into fixed-size chunks with surrounding context (RAG-style).search_*)Four retrieval modes over the same corpus. Data-first, pipe-friendly.
| Function | Query type | Use case |
|---|---|---|
search_regex(corpus, query) |
Regex pattern | Specific strings, KWIC with inline highlighting. |
search_dict(corpus, terms) |
Term vector | Exact phrases and MWEs; built-in dict_generations, dict_political. |
search_index(index, query) |
Keywords | BM25 ranked retrieval over a token index. |
search_vector(embeddings, query) |
Numeric vector | Semantic nearest-neighbor search; use util_fetch_embeddings() to embed. |
util_*)Build resources that the search functions use.
util_fetch_embeddings() -- Embed text through a local Ollama server (default all-minilm) or any OpenAI-compatible endpoint; the matrix feeds search_vector().util_find_abbreviations() -- Find in-text abbreviation definitions (e.g. "abscisic acid (ABA)", "A. thaliana"); the pairs can extend a search_dict() dictionary.corpus <- data.frame(
doc_id = "1",
text = paste("Arabidopsis thaliana seedlings were treated with abscisic acid (ABA).",
"In A. thaliana roots, ABA slowed growth.")
)
util_find_abbreviations(corpus, by = "doc_id")
#> doc_id short_form long_form method
#> 1: 1 ABA abscisic acid parenthetical
#> 2: 1 A. thaliana Arabidopsis thaliana taxonomic
textpress is designed to compose cleanly into retrieval-augmented generation pipelines.
Hybrid retrieval -- run search_index() and search_vector() over the same chunks, then merge with reciprocal rank fusion (RRF).
Context assembly -- nlp_roll_chunks() with context_size > 0 gives each chunk a focal sentence plus surrounding context, so retrieved passages are self-contained when passed to an LLM.
Because the stages exchange plain data frames, their outputs can also be inspected, filtered, saved, or passed to an LLM without conversion to a custom corpus class.
fetch_rss() + read_urls()fetch_wiki_urls() + fetch_wiki_refs()util_find_abbreviations(), abbreviation-aware dictionary searchsearch_regex(), KWICMIT © Jason Timm
citation("textpress")
Report bugs or request features at https://github.com/jaytimm/textpress/issues