• Documentation
  • Ergodiff
  • API References

API References

Class: Ergodiff

Constructor

ed = Ergodiff()

No parameter for the constructor of this class.

Functions

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

This function will return a tuple of three lists.

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.

The first dimension of changes is sentences. The second 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.

added_lines are generally used in reconstruction. If you simply want to get the difference and does not care about the reconstruction, you can ignore this one.

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
astrThe elder revision sentence.
bstrThe 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.

Last updated on December 7, 2022