使用R,如何获得"diff".两个弦? [英] Using R, how to get the "diff" of two strings?
问题描述
R函数的基本功能 diff
计算第一个差异,对于比较滞后的数据很有用.
The base R function diff
computes a first difference, useful for lagged data comparisons.
我正在寻找R中可访问的GNU diff
函数:https://www.computerhope.com/unix/udiff.htm
I am looking for the GNU diff
function accessible in R: https://www.computerhope.com/unix/udiff.htm
此功能对于版本控制很有用,但在自然语言处理中也可以用于识别两个相似文本元素之间的更改或编辑.这也是git等的基础引擎.
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.
理想情况下,该函数应为 gnudiff(text1,text2)
,如果将其绑定到 quanteda
或其他库,那就太好了.
Ideally the function would be gnudiff(text1,text2)
and if tied to quanteda
or another library, that would be awesome.
如何获取两个文本元素的 diff
?
How do I get the diff
of two text elements?
推荐答案
尝试使用 diffObj()
library(diffobj)
diffObj(text1, text2)
这篇关于使用R,如何获得"diff".两个弦?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!