Description Usage Slots Examples
View source: R/compare_matrices.R
Subtract over two word-context matrices to uncover different word-use patterns.
1 | compare_matrices(mat1, mat2, output = "mat")
|
mat1
A word-context matrix
mat2
A word-context matrix
output
A string (either "mat" or "vec".) If "mat", function will return a matrix (mat1 - mat2), made up of the shared rows and shared columns. If "vec", function will return a vector giving the Pearson correlation for each context word (row) shared by the matrices.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | # Get new matrix showing how Locke differs from peers.
data(locke)
data(nlaw)
data(eebo)
new_mat <- find_difference(locke, nlaw)
# For quick visualizations, create context dendrograms.
graph_context(new_mat, "property")
# For details: look at Z-scores of individual terms to see how Locke's usage differs.
sort(zscore(new_mat, "legislative"), decreasing = T)[1:10]
# Get similarity scores to see how differently each word is used.
vec = compare_matrices(locke, nlaw, output = "vec")
sort(vec)[1:50] # Display 50 least-similar words
vec["property"] # See how similar one word is to the context.
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.