mirror of
https://github.com/gradio-app/gradio.git
synced 2024-11-27 01:40:20 +08:00
ce47c48ebc
* first commit * changes * restore defualt_value name * changes * rm value= * rm value= * rm value= * changes * changes * changes * rename default_val to value * changes * changes * changes * changes * format * changes * changes * format * test fix Co-authored-by: Ali Abid <aliabid94@gmail.com>
32 lines
662 B
Python
32 lines
662 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="Initial text",
|
|
lines=3,
|
|
value="The quick brown fox jumped over the lazy dogs.",
|
|
),
|
|
gr.Textbox(
|
|
label="Text to compare",
|
|
lines=3,
|
|
value="The fast brown fox jumps over lazy dogs.",
|
|
),
|
|
],
|
|
gr.HighlightedText(label="Diff"),
|
|
)
|
|
if __name__ == "__main__":
|
|
demo.launch()
|