This function performs LDA topic modeling on the preprocessed reviews.
Examples
# \donttest{
# Create a temporary file with sample book IDs
temp_file <- tempfile(fileext = ".txt")
writeLines(c("1420", "2767052", "10210"), temp_file)
# Scrape reviews
reviews <- scrape_reviews(temp_file, num_reviews = 5, use_parallel = FALSE)
#> Total book IDs to process: 3
#> 2024-10-25 03:00:57.973065 scrape_goodreads_reviews: Completed! All book reviews extracted
#> Scraping run time = 7.86260986328125
#> Total books processed: 3
# Preprocess the reviews
preprocessed <- preprocess_reviews(reviews, english_only = TRUE)
# Fit LDA model
lda_model <- fit_lda(preprocessed$dtm, k = 2)
# Print model summary
print(lda_model)
#> A LDA_Gibbs topic model with 2 topics.
# Clean up: remove the temporary file
file.remove(temp_file)
#> [1] TRUE
# }