mshaffer
mshaffer

Reputation: 991

How to get the "diff" of two strings?

The base R function diff computes a first difference, useful for lagged data comparisons.

I am looking for the GNU diff function accessible in R: https://www.computerhope.com/unix/udiff.htm

This function is useful for version control, but also useful in natural language processes to identify changes or edits between two similar text elements. This is also an underlying engine of git and so on.

Ideally the function would be gnudiff(text1,text2) and if tied to quanteda or another library, that would be awesome.

How do I get the diff of two text elements?

Upvotes: 0

Views: 778

Answers (1)

stevec
stevec

Reputation: 52318

Try using diffObj()

library(diffobj)
diffObj(text1, text2)

Upvotes: 2

Related Questions