mirror of
https://github.com/gradio-app/gradio.git
synced 2024-11-27 01:40:20 +08:00
5f25eb6836
* changes
* changes
* add changeset
* changes
* changes
* fix box changes on website
* add changeset
* changes
* changes
* Revert "changes"
This reverts commit 189b4e844a
.
* chanegs
* changes
* changes
* changes
* changes
* add changeset
* Update fancy-bats-deny.md
---------
Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
Co-authored-by: aliabd <ali.si3luwa@gmail.com>
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
39 lines
855 B
Python
39 lines
855 B
Python
from difflib import Differ
|
|
|
|
import gradio as gr
|
|
|
|
|
|
def diff_texts(text1, text2):
|
|
d = Differ()
|
|
return [
|
|
(token[2:], token[0] if token[0] != " " else None)
|
|
for token in d.compare(text1, text2)
|
|
]
|
|
|
|
|
|
demo = gr.Interface(
|
|
diff_texts,
|
|
[
|
|
gr.Textbox(
|
|
label="Text 1",
|
|
info="Initial text",
|
|
lines=3,
|
|
value="The quick brown fox jumped over the lazy dogs.",
|
|
),
|
|
gr.Textbox(
|
|
label="Text 2",
|
|
info="Text to compare",
|
|
lines=3,
|
|
value="The fast brown fox jumps over lazy dogs.",
|
|
),
|
|
],
|
|
gr.HighlightedText(
|
|
label="Diff",
|
|
combine_adjacent=True,
|
|
show_legend=True,
|
|
color_map={"+": "red", "-": "green"}),
|
|
theme=gr.themes.Base()
|
|
)
|
|
if __name__ == "__main__":
|
|
demo.launch()
|