Learn R Programming

conversim (version 0.1.0)

semantic_sim_dyads: Calculate semantic similarity for multiple dyads

Description

This function calculates semantic similarity over a sequence of conversation exchanges for multiple dyads.

Usage

semantic_sim_dyads(conversations, method = "tfidf", window_size = 3, ...)

Value

A list containing the sequence of similarities for each dyad and the overall average similarity

Arguments

conversations

A data frame with columns 'dyad_id', 'speaker', and 'processed_text'

method

A character string specifying the method to use: "tfidf", "word2vec", or "glove"

window_size

An integer specifying the size of the sliding window

...

Additional arguments passed to semantic_similarity

Examples

Run this code
library(lme4)
convs <- data.frame(
  dyad_id = c(1, 1, 1, 1, 2, 2, 2, 2),
  speaker = c("A", "B", "A", "B", "C", "D", "C", "D"),
  processed_text = c("i love pizza", "me too favorite food",
                     "whats your favorite topping", "enjoy pepperoni mushrooms",
                     "i prefer pasta", "pasta delicious like spaghetti carbonara",
                     "ever tried making home", "yes quite easy make")
)
semantic_sim_dyads(convs, method = "tfidf", window_size = 2)

Run the code above in your browser using DataLab