powered by
This function calculates the semantic similarity between two conversations using either TF-IDF, Word2Vec, or GloVe embeddings approach.
semantic_similarity( conversation1, conversation2, method = "tfidf", model_path = NULL, dim = 100, window = 5, iter = 5 )
A numeric value representing the semantic similarity (between 0 and 1)
A character string representing the first conversation
A character string representing the second conversation
A character string specifying the method to use: "tfidf", "word2vec", or "glove"
A character string specifying the path to pre-trained GloVe file (required for "glove" method)
An integer specifying the dimensionality for Word2Vec embeddings (default: 100)
An integer specifying the window size for Word2Vec (default: 5)
An integer specifying the number of iterations for Word2Vec (default: 5)
conv1 <- "The quick brown fox jumps over the lazy dog" conv2 <- "A fast auburn canine leaps above an idle hound" semantic_similarity(conv1, conv2, method = "tfidf")
Run the code above in your browser using DataLab