使用 R,如何获得“diff"两个字符串? [英] Using R, how to get the "diff" of two strings?

查看:66
本文介绍了使用 R,如何获得“diff"两个字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基础 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆