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
Name | Type | Description |
---|---|---|
a | list[str] | List of sentences in the elder revision. |
b | list[str] | List of sentences in the newer revision. |
Returns
This function will return a tuple of three lists.
Name | Type | Description |
---|---|---|
old_sentences | list[str] | List of sentences of the elder revision. |
changes | list[list[[int, str, str]]] | Change-set between the elder and the newer revision. |
added_lines | list[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
Name | Type | Description |
---|---|---|
a | str | The elder revision sentence. |
b | str | The newer revision sentence. |
Returns
This function will return a tuple of three lists.
Name | Type | Description |
---|---|---|
changes | list[[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.