Ergodiff

API Reference

ed.get_diff(a, b)

This function is computing the difference between two chunks of sentences. You are expected to pass two lists of strings in. For only comparing two sentences, you can use ed.get_sentence_diff(a, b) instead.

old_sentences, changes, added_lines = ed.get_diff(a, b)

Parameters

NameTypeDescription
alist[str]

List of sentences in the elder revision.

blist[str]

List of sentences in the newer revision.

Returns

NameTypeDescription
old_sentenceslist[str]

List of sentences of the elder revision.

changeslist[list[[int, str, str]]]

Change-set between the elder and the newer revision.

added_lineslist[int]

List of indexes that need to add a new line.

ed.get_sentence_diff(a, b)

This function is computing the difference between two sentences (rather than two pools of sentences). For chunk level computation, you can use ed.get_diff(a, b) instead.

changes = ed.get_sentence_diff(a, b)

Parameters

NameTypeDescription
astr

The elder revision sentence.

bstr

The newer revision sentence.

Returns

This function will return a tuple of three lists.

NameTypeDescription
changeslist[[int, str, str]]

Change-set between the elder and the newer revision.

The first dimension is the changes in each sentence. Each change is a tuple of three elements: the index of the word, the word in the elder revision, and the word in the newer revision.