## ----setup, include = FALSE---------------------------------------------------
knitr::opts_chunk$set(
  collapse  = TRUE,
  comment   = "#>",
  fig.width = 8,
  fig.height = 5,
  out.width = "100%",
  warning   = FALSE,
  message   = FALSE,
  eval      = FALSE
)

## ----install, eval = FALSE----------------------------------------------------
# # From CRAN
# install.packages("orisma")
# 
# # Development version
# remotes::install_github("Aguilar-Elena/orisma")

## ----three_lines--------------------------------------------------------------
# library(orisma)
# 
# refs   <- orm_load("path/to/ris/files/")
# result <- orm_run(refs, topic = "Metal additive manufacturing - OHS")
# orm_report(result, lang = "en", out_dir = "my_outputs/")

## ----load---------------------------------------------------------------------
# library(orisma)
# 
# refs <- orm_load(
#   path = "path/to/ris/files/",
#   lang = "en"
# )

## ----dedup--------------------------------------------------------------------
# # Deduplication runs automatically inside orm_run()
# # but can be called independently:
# deduped <- orm_dedup(refs, fuzzy_threshold = 0.90, verbose = TRUE)

## ----dict---------------------------------------------------------------------
# dict <- orm_dict()
# orm_dict_categories(dict)

## ----dict_extend--------------------------------------------------------------
# # Add terms to an existing category
# dict <- orm_dict_add_terms(dict, "nanomaterials",
#                            c("nano-aerosol", "NOAA particle"))
# 
# # Add a completely new category
# dict <- orm_dict_add_category(dict,
#   key      = "laser_safety",
#   label_en = "Laser safety in AM processes",
#   label_es = "Seguridad laser en procesos AM",
#   terms    = c("laser safety", "laser hazard", "laser exposure")
# )

## ----extract------------------------------------------------------------------
# mx <- orm_extract(deduped, dict = dict,
#                   fields  = c("title", "abstract", "keywords"),
#                   verbose = TRUE)
# print(mx)

## ----wrdi---------------------------------------------------------------------
# result <- orm_run(refs, topic = "Metal additive manufacturing - OHS")
# cat("Global WRDI:", result$WRDI_global, "\n")

## ----rcs----------------------------------------------------------------------
# ind <- result$indicators[result$indicators$n_records > 0, ]
# ind[order(-ind$RCS), c("label", "n_records", "RCS")]

## ----mgp----------------------------------------------------------------------
# print(result$MGP)

## ----autodim------------------------------------------------------------------
# dims <- orm_autodim(result$mx, method = "blocks", verbose = TRUE)
# print(dims)

## ----dim_matrix---------------------------------------------------------------
# mat <- orm_dim_matrix(result, dims,
#                       out_dir = "outputs/plots/",
#                       lang    = "en")

## ----ass----------------------------------------------------------------------
# mx  <- orm_ass(result$mx, verbose = TRUE)
# orm_ass_plot(mx, lang = "en")

## ----bridge-------------------------------------------------------------------
# mx <- orm_bridge(result$mx, verbose = TRUE)

## ----ranking------------------------------------------------------------------
# ranking <- orm_ranking(result$mx, top_n = 10, lang = "en")
# print(ranking)

## ----risk_sheet---------------------------------------------------------------
# orm_risk_sheet(result,
#   topic           = "Metal additive manufacturing",
#   search_strategy = "Systematic search in WoS and Scopus (2015-2026).",
#   out_dir         = "outputs/",
#   lang            = "en"
# )

## ----extraction---------------------------------------------------------------
# orm_extraction_matrix(result$mx, result,
#   top_n   = 20,
#   out_dir = "outputs/",
#   lang    = "en"
# )

## ----validate-----------------------------------------------------------------
# # Step 1: Generate validation sample
# val_path <- orm_validate(result$mx,
#   n_sample = 30,
#   out_dir  = "outputs/validation/",
#   lang     = "en"
# )
# 
# # Step 2: Open the CSV, fill in manual_* columns (0 or 1)
# # Step 3: Compute Cohen's Kappa
# kappa_results <- orm_validate(result$mx,
#   validation_file = val_path,
#   out_dir         = "outputs/validation/",
#   lang            = "en"
# )
# print(kappa_results)

## ----session------------------------------------------------------------------
# sessionInfo()

