Using R, how to get the “diff” of two strings?

痴心易碎 提交于 2021-02-11 13:10:38

问题


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?


回答1:


Try using diffObj()

library(diffobj)
diffObj(text1, text2)


来源:https://stackoverflow.com/questions/64999090/using-r-how-to-get-the-diff-of-two-strings

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!