I found some free code for doing text file compares. The code was, um, not appealing, but the algorithm was simple enough I could write my own version. I suppose you could adapt it to compare words instead of lines. It would fall down at comparing letters, tho, with too many matches. Here's some info from my package.html. This gives the broadest of hints. It would be a rather advanced task to go from here to code. But if you want to give it a shot, see how far you get and come back with code samples of your own.
TextDiff compares two text files or arrays of strings and generates a report of edit commands that would transform Old to New.
The algorithm (but no code) was taken from Java code by Ian F. Darwin,
ian@darwinsys.com, January, 1997. Darwin's code was a translation of a C program by D. C. Lindsay, C (1982-1987)
The algorithm is:
For each each unique line of text create a symbol. The symbol state is: OldOnly, NewOnly, UniqueMatch (both files exactly once), or Other.
For each line, create a LineInfo object. Set state = symbol state and establish bidirectional links between UniqueMatch lines in the two files.
For each UniqueMatch in old create a "match block". Stretch match blocks forward and backward to include matching lines with any state, including other match blocks.
Build a Report of edit commands that can be used to tranform Old into New.
Matching blocks generate match or move commands. Non-matching blocks generate insert, append, delete or change commands.
Iterate the commands to generate a report.
The DefaultReportWriter prints a human-friendly report to a PrintStream such as System.out. One could implement custom report writers to create machine-readable reports such as concrete editor commands.