Home >Backend Development >PHP Tutorial >How to compare two paragraphs of text in php?

How to compare two paragraphs of text in php?

WBOY
WBOYOriginal
2016-09-27 14:04:311291browse

Given two paragraphs of text, how to compare them?

How to give two paragraphs of text, just like the review function of Word, mark the modification process, or similar to the correction process after dictation, compare the insertion and modification (based on characters) between two strings (paragraphs) ), delete function. Github's examples are good, but they don't seem to be minimal edits, not word-for-word operations.

For example:

Sentence 1: Why I Cann't changed it. Becuase we can't.

Sentence 2: Why we can't change it now? Because you can.

The program can compare these two sentences, find the differences, automatically skip the same parts, and mark the differences.

How does php implement this algorithm? Also give a score. Is it related to edit distance? The search keyword is: php diff? Or compare strings?

Take Hujiang as an example: http://ting.hujiang.com/mansu...

How to compare two paragraphs of text in php?

I feel that https://github.com/kijtra/tex... This algorithm is not as easy to use as Hujiang’s:

How to compare two paragraphs of text in php?

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn