Learn R Programming

conversim (version 0.1.0)

topic_similarity: 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)

Value

A numeric value representing the topic similarity

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

Examples

Run this code
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)

Run the code above in your browser using DataLab