I'm using the python difflib to calculate the diff between two plaintext English paragraphs.
The paragraphs are very similar- one has an extra leading and ending sentence. There are also minor differences between the characters.
Unfortunately, I'm getting very bad results. It seems like a character in the beginning of the diff is throwing it off and it sprinkles random characters throughout.
Websites like diffchecker.com have no problem calculating the diff. I also notice that if I decrease the window of the difflib to ignore the first sentence, it computes the diff correctly. Has anyone else noticed this issue?
Attaching my code and the sample passages below. Thanks so much.
import difflib
s1 = "Ableton Live also supports Audio To MIDI, which converts audio samples into a sequence of MIDI notes using three different conversion methods including conversion to Melody, Harmony, or Rhythm. Once finished, Live will create a new MIDI track containing the fresh MIDI notes along with an instrument to play back the notes. Audio to midi conversion is not always 100% accurate and may require the artist or producer to manually adjust some notes.[14] See Fourier transform.Envelopes[edit]Almost all of the parameters in Live can be automated by envelopes which may be drawn either on clips, in which case they will be used in every performance of that clip, or on the entire arrangement. The most obvious examples are volume and track panning, but envelopes are also used in Live to control parameters of audio devices such as the root note of a resonator or a filter’s cutoff frequency. Clip envelopes may also be mapped to MIDI controls, which can also control parameters in real-time using sliders, faders and such. Using the global transport record function will also record changes made to these parameters, creating an envelope for them.User interface[edit]Much of Live’s interface comes from being designed for use in live performance, as well as for production.[15] There are few pop up messages or dialogs. Portions of the interface are hidden and shown based on arrows which may be clicked to show or hide a certain segment (e.g. to hide the instrument/effect list or to show or hide the help box)."
s2 = "Once finished, Live will create a new MIDI track containing the fresh MIDI notes along with an instrument to play back the notes. Audio to midi conversion is not always 100% accurate and may require the artist or producer to manually adjust some notes. [14] See Fourier transform . Envelopes[ edit ] Almost all of the parameters in Live can be automated by envelopes which may be drawn either on clips, in which case they will be used in every performance of that clip, or on the entire arrangement. The most obvious examples are volume and track panning, but envelopes are also used in Live to control parameters of audio devices such as the root note of a resonator or a filter’s cutoff frequency. Clip envelopes may also be mapped to MIDI controls, which can also control parameters in real-time using sliders, faders and such. Using the global transport record function will also record changes made to these parameters, creating an envelope for them. User interface[ edit ] Much of Live’s interface comes from being designed for use in live performance, as well as for production."
if __name__ == "__main__":
res = [d for d in difflib.ndiff(s1, s2)]
print(res)