string/text_diff_structured_utils library
Structured diff of two texts by sentences and by words — roadmap #415.
Produces a UI-friendly edit script (a list of equal/insert/delete ops in order) rather than a rendered string, so a caller can color, animate, or summarize the changes. The generic diffSequences engine is reused for both the word-level and sentence-level conveniences.
Enums
- SeqDiffKind
- The kind of change an edit-script step represents.
Functions
-
diffSentences(
String oldText, String newText) → List< SeqDiffOp< String> > -
Sentence-level structured diff of
oldTextvsnewText, reusingtokenizeSentencesto split on sentence boundaries. Audited: 2026-06-12 11:26 EDT -
diffSequences<
T> (List< T> a, List<T> b) → List<SeqDiffOp< T> > -
Computes the LCS-based edit script that turns
aintob: a list ofequal/delete/insertops in input order.deleteitems appear only ina,insertitems only inb, and theequalitems are their longest common subsequence. O(n·m) time and space. Audited: 2026-06-12 11:26 EDT -
diffWords(
String oldText, String newText) → List< SeqDiffOp< String> > -
Word-level structured diff of
oldTextvsnewText, reusingtokenizeWordsto split into words (punctuation stripped). Audited: 2026-06-12 11:26 EDT