topic_similarity: Calculate topic similarity between two conversations

View source: R/main_functions.R

topic_similarityR Documentation

Calculate topic similarity between two conversations

Description

This function calculates the topic similarity between two conversations using either Latent Dirichlet Allocation (LDA) or Latent Semantic Analysis (LSA).

Usage

topic_similarity(conv1, conv2, method = "lda", num_topics = 2)

Arguments

conv1

A character vector representing the first conversation

conv2

A character vector representing the second conversation

method

A character string specifying the method to use: "lda" or "lsa"

num_topics

An integer specifying the number of topics to use in the model

Value

A numeric value representing the topic similarity

Examples

conv1 <- c("I love pizza", "Pizza is my favorite food")
conv2 <- c("I prefer pasta", "Pasta is delicious")
topic_similarity(conv1, conv2, method = "lda", num_topics = 2)
topic_similarity(conv1, conv2, method = "lsa", num_topics = 2)

conversim documentation built on Sept. 20, 2024, 5:09 p.m.