Learn R Programming

lingmatch

An all-in-one R package for the assessment of linguistic matching and/or accommodation.

features

  • Input raw text, a document-term matrix (DTM), or LIWC output.
  • Apply various weighting functions to a DTM.
  • Measure similarity and/or accommodation with various metrics.
  • Calculate standard forms of Language Style Matching (LSM) and Latent Semantic Similarity (LSS).

resources

installation

Download R from r-project.org, then install the package from an R console:

Release (version 1.0.7)

install.packages("lingmatch")

Development (version 1.0.8)

# install.packages("remotes")
remotes::install_github("miserman/lingmatch")

And load the package:

library(lingmatch)

examples

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:

text = c(
  "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
inquirer_cats = lma_process(text, dict = "inquirer", dir = "~/Dictionaries")

# with a latent semantic space
glove_vectors = lma_process(text, space = "glove", dir = "~/Latent Semantic Spaces")

Or process the texts step by step, then measure similarity between each:

dtm = lma_dtm(text)
dtm_weighted = lma_weight(dtm)
dtm_categorized = lma_termcat(dtm_weighted, lma_dict(1:9))
similarity = lma_simets(dtm_categorized, metric = "canberra")

Or do that within a single function call:

similarity = lingmatch(
  text, weight = "frequency", dict = lma_dict(1:9), metric = "canberra"
)$sim

Or, if you want a standard form (as in this example), specify a default:

similarity = lingmatch(text, type = "lsm")$sim

Copy Link

Version

Install

install.packages('lingmatch')

Monthly Downloads

266

Version

1.0.7

License

GPL (>= 2)

Maintainer

Micah Iserman

Last Published

May 3rd, 2024

Functions in lingmatch (1.0.7)

lma_termcat

Document-Term Matrix Categorization
standardize.lspace

Standardize a Latent Semantic Space
lma_simets

Similarity Calculations
read.segments

Read and Segment Multiple Texts
select.lspace

Select Latent Semantic Spaces
lma_process

Process Text
report_term_matches

Generate a Report of Term Matches
lma_weight

Document-Term Matrix Weighting
read.dic

Read/Write Dictionary Files
select.dict

Select Dictionaries
download.lspace

Download Latent Semantic Spaces
lma_dtm

Document-Term Matrix Creation
lma_initdirs

Initialize Directories for Dictionaries and Latent Semantic Spaces
lingmatch

Linguistic Matching and Accommodation
lma_dict

English Function Word Category and Special Character Lists
lma_lspace

Latent Semantic Space (Embeddings) Operations
download.dict

Download Dictionaries
dictionary_meta

Assess Dictionary Categories Within a Latent Semantic Space
lma_patcat

Categorize Texts
lma_meta

Calculate Text-Based Metastatistics