SentenceSimilarity: Get similar sentences.

SentenceSimilarityR Documentation

Get similar sentences.

Description

Get similar sentences.

Get similar sentences.

Methods

getSentenceVectors(method = c("pos", "openNLP"), f = mean, stopwords = tm::stopwords("de"), tfidf = FALSE, verbose = TRUE)

Public fields

partition

a partition

Methods

Public methods


Method getSentenceVectors()

Usage
SentenceSimilarity$getSentenceVectors(
  method = c("pos", "openNLP"),
  f = mean,
  stopwords = tm::stopwords("de"),
  tfidf = FALSE,
  verbose = TRUE
)

Method getSentenceVector()

Usage
SentenceSimilarity$getSentenceVector(sentence)

Method getSentenceSimilarity()

Usage
SentenceSimilarity$getSentenceSimilarity(x, n = NULL, text = TRUE)

Method getSimilarityMatrix()

Usage
SentenceSimilarity$getSimilarityMatrix()

Method getSimilarSentences()

Usage
SentenceSimilarity$getSimilarSentences(i, n = 10)

Method clone()

The objects of this class are cloneable with this method.

Usage
SentenceSimilarity$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Examples

## Not run: 
library(R6)
library(NLP)
library(openNLP)
library(openNLPmodels.de)
library(polmineR)

filename <- "/Users/blaette/Lab/tmp/word2vec/word2vec/data/plprbt_word2vec.csv"
W2V <- Word2Vec$new()
W2V$load(filename)
merkel <- partition("PLPRBT", speaker_name = "Angela Merkel", speaker_year = "2015")
S <- SentenceSimilarity$new()
S$partition <- merkel
S$word2vec <- W2V$vector_matrix
S$threads <- 3
S$getSentenceVectors(method = "pos", f = sum)
S$getSimilarityMatrix()

i <- 549
S$sentences[[i]]
sentence <- c("Kriminelle", "Ausländer", "raus", "und", "zwar", "schnell")
S$getSentenceSimilarity(sentence)

## End(Not run)

PolMine/polmineR.misc documentation built on Nov. 23, 2022, 9:01 p.m.