An all-in-one R package for the assessment of linguistic matching and/or accommodation.
Download R from r-project.org, then install the package from an R console:
Release (version 1.0.4)
install.packages('lingmatch')
Development (version 1.0.5)
# install.packages('remotes')
::install_github('miserman/lingmatch') remotes
And load the package:
library(lingmatch)
Can make a quick comparison between two bits of text; by default this will give the cosine similarity between raw word-count vectors:
lingmatch('First text to look at.', 'Text to compare that text with.')
Or, given a vector of texts:
= c(
text "Why, hello there! How are you this evening?",
"I am well, thank you for your inquiry!",
"You are a most good at social interactions person!",
"Why, thank you! You're not all bad yourself!"
)
Process the texts in one step:
# with a dictionary
= lma_process(text, dict = 'inquirer', dir = '~/Dictionaries')
inquirer_cats
# with a latent semantic space
= lma_process(text, space = 'glove', dir = '~/Latent Semantic Spaces') glove_vectors
Or process the texts step by step, then measure similarity between each:
= lma_dtm(text)
dtm = lma_weight(dtm)
dtm_weighted = lma_termcat(dtm_weighted, lma_dict(1:9))
dtm_categorized = lma_simets(dtm_categorized, metric = 'canberra') similarity
Or do that within a single function call:
= lingmatch(
similarity weight = 'frequency', dict = lma_dict(1:9), metric = 'canberra'
text, $sim )
Or, if you want a standard form (as in this example), specify a default:
= lingmatch(text, type = 'lsm')$sim similarity