mirror of
https://github.com/gradio-app/gradio.git
synced 2024-12-27 02:30:17 +08:00
cc0cff893f
- black formatting - isort formatting
26 lines
559 B
Python
26 lines
559 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)
|
|
]
|
|
|
|
|
|
iface = gr.Interface(
|
|
diff_texts,
|
|
[
|
|
gr.inputs.Textbox(
|
|
lines=3, default="The quick brown fox jumped over the lazy dogs."
|
|
),
|
|
gr.inputs.Textbox(lines=3, default="The fast brown fox jumps over lazy dogs."),
|
|
],
|
|
gr.outputs.HighlightedText(),
|
|
)
|
|
if __name__ == "__main__":
|
|
iface.launch()
|