Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,9 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
-
def greet(name):
|
| 4 |
-
return "Hello " + name + "!!"
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#import gradio as gr
|
| 2 |
+
|
| 3 |
+
#def greet(name):
|
| 4 |
+
# return "Hello " + name + "!!"
|
| 5 |
+
|
| 6 |
+
#demo = gr.Interface(fn=greet, inputs="text", outputs="text")
|
| 7 |
+
#demo.launch()
|
| 8 |
+
|
| 9 |
+
#==============================================================
|
| 10 |
+
from difflib import Differ
|
| 11 |
+
|
| 12 |
import gradio as gr
|
| 13 |
|
|
|
|
|
|
|
| 14 |
|
| 15 |
+
def diff_texts(text1, text2):
|
| 16 |
+
d = Differ()
|
| 17 |
+
return [
|
| 18 |
+
(token[2:], token[0] if token[0] != " " else None)
|
| 19 |
+
for token in d.compare(text1, text2)
|
| 20 |
+
]
|
| 21 |
+
|
| 22 |
|
| 23 |
+
demo = gr.Interface(
|
| 24 |
+
diff_texts,
|
| 25 |
+
[
|
| 26 |
+
gr.Textbox(
|
| 27 |
+
label="Text 1",
|
| 28 |
+
info="Initial text",
|
| 29 |
+
lines=3,
|
| 30 |
+
value="The quick brown fox jumped over the lazy dogs.",
|
| 31 |
+
),
|
| 32 |
+
gr.Textbox(
|
| 33 |
+
label="Text 2",
|
| 34 |
+
info="Text to compare",
|
| 35 |
+
lines=3,
|
| 36 |
+
value="The fast brown fox jumps over lazy dogs.",
|
| 37 |
+
),
|
| 38 |
+
],
|
| 39 |
+
gr.HighlightedText(
|
| 40 |
+
label="Diff",
|
| 41 |
+
combine_adjacent=True,
|
| 42 |
+
show_legend=True,
|
| 43 |
+
color_map={"+": "red", "-": "green"}),
|
| 44 |
+
theme=gr.themes.Base()
|
| 45 |
+
)
|
| 46 |
+
if __name__ == "__main__":
|
| 47 |
+
demo.launch()
|