% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/zzz.R
\docType{package}
\name{rapidcodeR-package}
\alias{rapidcodeR}
\alias{rapidcodeR-package}
\title{rapidcodeR: Optimized Data Analysis System for AI-Based Text Processing}
\description{
A high-performance R package for extracting machine-readable variables from
natural language text using AI APIs. The package is optimized for speed and
cost efficiency through parallel processing and direct CSV-formatted responses
from language models.
}
\section{Funding}{

This work is financed in large part by the Research Council of Norway
(grant #324931).
}

\section{Key Features}{

\itemize{
\item \strong{Parallel Processing}: Distributes work across multiple CPU cores for maximum speed
\item \strong{Cost Optimization}: Uses batch processing to minimize API calls
\item \strong{Multi-Provider Support}: Works with both OpenAI GPT and GROQ AI services
\item \strong{Robust Error Handling}: Automatic retry mechanisms for failed extractions
\item \strong{CSV-Optimized Output}: AI models return structured data for efficient parsing
\item \strong{Missing Data Recovery}: Secondary processing stage for failed extractions
}
}

\section{Main Functions}{

\describe{
\item{\code{\link{parallel_execute}}}{Main function for parallel text processing}
\item{\code{\link{set_api_specs}}}{Configure API specifications for AI services}
\item{\code{\link{set_coding_instruction}}}{Define how AI should extract variables}
\item{\code{\link{set_parameters}}}{Configure processing parameters}
\item{\code{\link{calculate_overlap}}}{Assess reliability across multiple runs}
}
}

\section{Workflow}{

\enumerate{
\item Set up API specifications using \code{set_api_specs()}
\item Configure processing parameters with \code{set_parameters()} (optional)
\item Define extraction instructions with \code{set_coding_instruction()}
\item Process data with \code{parallel_execute()}
\item Optionally assess reliability with \code{calculate_overlap()}
}
}

\section{Data Format}{

Input data should contain columns specified by \code{set_parameters()}:
\itemize{
\item ID column: Unique identifier for each text (default column 1)
\item Text column: The text content to be processed (default column 2)
}

Output contains configurable columns: id, language, text, and N extracted variables (Var1-VarN).
}

\examples{
\dontrun{
# Basic workflow
library(rapidcodeR)

# 1. Set up API specifications
set_api_specs(provider = "OpenAI", model = "gpt-4", temp = 0.7, api_key = "your_openai_key")

# 2. Configure processing parameters (optional)
set_parameters(n_variables = 4, id_column = 1, text_column = 2, sep = ",")

# 3. Define what to extract
instruction <- paste(
  "Extract sentiment and topic from each post.",
  "Return as CSV: id,language,text,sentiment,confidence,topic,relevance"
)
set_coding_instruction(instruction)

# 4. Process your data
results <- parallel_execute(
  test_data = my_text_data,
  slicing_n = 240,     # Process 240 random posts
  cores = 4,           # Use 4 CPU cores
  # Provider determined by set_api_specs()
)

# 5. Check reliability (optional)
run1 <- parallel_execute(my_data, 100, cores = 4, seed = 123)
run2 <- parallel_execute(my_data, 100, cores = 4, seed = 123)
agreement <- calculate_overlap(list(run1, run2))
}

}
\author{
\strong{Maintainer}: Gabriel Lönn \email{g.e.lonn@stv.uio.no}

Authors:
\itemize{
  \item Gabriel Lönn \email{g.e.lonn@stv.uio.no}
}

Other contributors:
\itemize{
  \item Sebastian Schutte (Original code and package idea provided by.) [contributor]
}

}
\keyword{internal}
