Maison  >  Article  >  développement back-end  >  php如何比对两段文字?

php如何比对两段文字?

WBOY
WBOYoriginal
2016-09-27 14:04:311218parcourir

给出两段文字,如何进行比对?

就是如何给出两段文字,能够想word的审校功能一样,标出修改过程,或者类似听写之后的批改过程,比对出来两个字符串(段落)之间的插入、修改(基于字符)、删除功能。github的范例很好,但似乎不是最小编辑,不是逐词操作。

举个例子:

第1句话:Why I Cann't changed it. Becuase we can't.

第2句话:Why we can't change it now? Because you can.

程序能够对这两个句子进行对比,找到不同之处,自动跳过相同的部分,标记出来不一样的地方。

php如何实现这个算法?同时给出一个分数。是不是跟编辑距离有关?搜索关键词是:php diff?还是 compare strings?

以沪江为例:http://ting.hujiang.com/mansu...

php如何比对两段文字?

感觉https://github.com/kijtra/tex...这个算法不如沪江的好用:

php如何比对两段文字?

Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn