knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
  # fig.path = "/man/figures/"
)

Scripting

Create a list of files:

my_files <- list.files(path = '../man/files/', pattern = '.doc', full.names = TRUE)
my_files

The first 3 documents are different drafts of the same paper, so we would expect them to be similar to each other. The last document is a draft of a different paper, so it should be dissimilar to the first 3. All files are about 45K words long.

Now we can use cheatR to find duplicates.

The only function, catch_em, takes the following input arguments:

library(cheatR)
results <- catch_em(flist = my_files,
                    n_grams = 10, time_lim = 1) # defaults

The resulting list contains a matrix with the similarity values between each pair of documents:

results

You can also plot the relational graph if you'd like to get a more clear picture of who copied from who.

plot(results, weight_range = c(0.7, 1), remove_lonely = FALSE)


mattansb/cheatR documentation built on April 22, 2022, 4:43 p.m.