OfficeDiff
OfficeIMO.Diff
Computes edit scripts between sequences: generic items with a comparer, or text split into lines, words or characters.
Inheritance
- object
- OfficeDiff
Remarks
Items are interned to integer ids first, so the comparer is called once per item rather than once per comparison. Every result is complete: when a work or time limit stops the alignment, the remaining regions are reported as whole deletions and insertions and OfficeDiffResult<T>.LimitReached is set.
Methods
public static OfficeDiffResult<OfficeTextToken> CompareCharacters(string? oldText, string? newText, OfficeDiffOptions? options = null, CancellationToken cancellationToken = default) #Compares two texts by user-perceived character (grapheme cluster).
Parameters
- oldText string?
- newText string?
- options OfficeIMO.Diff.OfficeDiffOptions? = null
- cancellationToken System.Threading.CancellationToken = default
public static OfficeDiffResult<OfficeTextToken> CompareLines(string? oldText, string? newText, OfficeDiffOptions? options = null, CancellationToken cancellationToken = default) #Compares two texts line by line. Line terminators are part of each line.
Parameters
- oldText string?
- newText string?
- options OfficeIMO.Diff.OfficeDiffOptions? = null
- cancellationToken System.Threading.CancellationToken = default
public static OfficeDiffResult<OfficeTextToken> CompareTokens(IReadOnlyList<OfficeTextToken> oldTokens, IReadOnlyList<OfficeTextToken> newTokens, OfficeDiffOptions? options = null, CancellationToken cancellationToken = default) #Compares two token sequences produced by OfficeTextTokenizer or by a caller, honouring the text settings in options.
Parameters
- oldTokens System.Collections.Generic.IReadOnlyList<OfficeIMO.Diff.OfficeTextToken>
- newTokens System.Collections.Generic.IReadOnlyList<OfficeIMO.Diff.OfficeTextToken>
- options OfficeIMO.Diff.OfficeDiffOptions? = null
- cancellationToken System.Threading.CancellationToken = default
public static OfficeDiffResult<OfficeTextToken> CompareWords(string? oldText, string? newText, OfficeDiffOptions? options = null, CancellationToken cancellationToken = default) #Compares two texts word by word (see OfficeTextTokenizer.Words).
Parameters
- oldText string?
- newText string?
- options OfficeIMO.Diff.OfficeDiffOptions? = null
- cancellationToken System.Threading.CancellationToken = default
public static OfficeDiffResult<T?> Compare<T>(IReadOnlyList<T?> oldItems, IReadOnlyList<T?> newItems, IEqualityComparer<T?>? comparer = null, OfficeDiffOptions? options = null, CancellationToken cancellationToken = default) #Compares two sequences.
Type Parameters
- T
Parameters
- oldItems System.Collections.Generic.IReadOnlyList<T?>
- Old sequence.
- newItems System.Collections.Generic.IReadOnlyList<T?>
- New sequence.
- comparer System.Collections.Generic.IEqualityComparer<T?>? = null
- Item comparer. Defaults to EqualityComparer<T>.Default.
- options OfficeIMO.Diff.OfficeDiffOptions? = null
- Diff settings.
- cancellationToken System.Threading.CancellationToken = default
- Cancels the alignment.
Returns
OfficeDiffResult<T?>