bigghuggs commited on
Commit
8239c42
·
verified ·
1 Parent(s): 27d8732

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -0
app.py CHANGED
@@ -16,6 +16,39 @@ demo = gr.Interface(fn=greet, inputs='text', outputs="text")
16
  demo.launch()
17
  """
18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  import gradio as gr
20
  import json
21
  import time
 
16
  demo.launch()
17
  """
18
 
19
+ def diff_texts(text1, text2):
20
+ d = Differ()
21
+ return [
22
+ (token[2:], token[0] if token[0] != " " else None)
23
+ for token in d.compare(text1, text2)
24
+ ]
25
+
26
+ demo = gr.Interface(
27
+ diff_texts,
28
+ [
29
+ gr.Textbox(
30
+ label="Text 1",
31
+ info="Initial text",
32
+ lines=3,
33
+ value="The quick brown fox jumped over the lazy dogs.",
34
+ ),
35
+ gr.Textbox(
36
+ label="Text 2",
37
+ info="Text to compare",
38
+ lines=3,
39
+ value="The fast brown fox jumps over lazy dogs.",
40
+ ),
41
+ ],
42
+ gr.HighlightedText(
43
+ label="Diff",
44
+ combine_adjacent=True,
45
+ show_legend=True,
46
+ color_map={"+": "red", "-": "green"}),
47
+ theme=gr.themes.Base()
48
+ )
49
+ if __name__ == "__main__":
50
+ demo.launch()
51
+
52
  import gradio as gr
53
  import json
54
  import time