Given two strings, I’d like to be able to — in Python — be able to determine which words have been added and which words have been removed between the two. I’ve seen difflib, but apparently it cannot do it.
For example: given ‘hello my name is’ and ‘hello my guys is’, it would return [‘guys’] as added words, and [‘name’] as removed words. Thanks a lot.
EDIT: Probably the example I gave wasn’t the best. It should also work without spaces between the current text and the new text. Maybe using difflib to get all the new sections, and then split with regexp “\b”. I’ll give it a try.
This isn’t particularly pretty but seems to work for most cases I can think of. I’m sure this can be tidied up a lot too and should be easy to make case insensitive.
gives