Compare two strings, show differences

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to be able to easily see what changes were made from original
to updated sentences (words added/removed/changed). I'm not too concerned about speed, just looking for something. The compared text will be anywhere from a word or two to multiple paragraphs.

An example:

Original sentence:
The brown dog ran outside at night. During the day, the brown dog slept.

Updated sentence:
The big brown dog ran outside when dark. During the day, it slept.


Ideally, the solution would display the differences in the browser, but I'm open to other ideas (creating txt documents out of the strings and comparing them with Word... but that's a question for another discussion area, purchase something third party, etc.).

Most of what I've found shows which line of text was modified. I'm looking for word differences.

Thank you,
Nathan Rosaaen
 
Nathan,
If you need third party tool, check my Compare It! from
http://www.grigsoft.com/.

If you want to implement it yourself, search for LCS (Longest Common
Subsequence) realization. It will find difference between 2 strings on
char level. If you need word level only, just hash words, your text
will become set of hashes. Same algorithm will compare results and get
you word differences.

If you will have more questions on topic, feel free to contact me
through site's form.

Regards,

Igor Green
http://www.grigsoft.com
Compare It! + Synchronize It! : Files and folders comparison never was
easier!
 
BeyondCompare

Nathan Rosaaen said:
I want to be able to easily see what changes were made from original
to updated sentences (words added/removed/changed). I'm not too concerned
about speed, just looking for something. The compared text will be anywhere
from a word or two to multiple paragraphs.
An example:

Original sentence:
The brown dog ran outside at night. During the day, the brown dog slept.

Updated sentence:
The big brown dog ran outside when dark. During the day, it slept.


Ideally, the solution would display the differences in the browser, but
I'm open to other ideas (creating txt documents out of the strings and
comparing them with Word... but that's a question for another discussion
area, purchase something third party, etc.).
 
Back
Top