TextCompare API#
Bases: AnyWidget
Side-by-side text comparison widget with hover-based match highlighting.
Compares two texts and highlights matching word sequences, useful for plagiarism detection or finding shared passages between documents.
Examples:
compare = TextCompare(
text_a="The quick brown fox jumps over the lazy dog.",
text_b="A quick brown fox leaps over a lazy dog."
)
compare
Create a TextCompare widget.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text_a
|
str
|
First text to compare. |
''
|
text_b
|
str
|
Second text to compare. |
''
|
min_match_words
|
int
|
Minimum number of consecutive words to consider a match. |
3
|
**kwargs
|
Any
|
Forwarded to |
{}
|
Source code in wigglystuff/text_compare.py
Synced traitlets#
| Traitlet | Type | Notes |
|---|---|---|
text_a |
str |
First text to compare. |
text_b |
str |
Second text to compare. |
matches |
list |
List of detected matches, each with start_a, end_a, start_b, end_b, text, and word_count. |
selected_match |
int |
Index of the currently hovered match (-1 if none). |
min_match_words |
int |
Minimum consecutive words to consider a match (default: 3). |