aliabd HF staff commited on
Commit
6b6d1b4
1 Parent(s): dfd1cc9

Upload with huggingface_hub

Browse files
Files changed (5) hide show
  1. README.md +6 -7
  2. __pycache__/run.cpython-36.pyc +0 -0
  3. requirements.txt +1 -0
  4. run.py +34 -0
  5. screenshot.png +0 -0
README.md CHANGED
@@ -1,12 +1,11 @@
 
1
  ---
2
- title: Diff Texts Main
3
- emoji: 🦀
4
- colorFrom: yellow
5
- colorTo: gray
6
  sdk: gradio
7
  sdk_version: 3.6
8
- app_file: app.py
9
  pinned: false
10
  ---
11
-
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
+
2
  ---
3
+ title: diff_texts_main
4
+ emoji: 🔥
5
+ colorFrom: indigo
6
+ colorTo: indigo
7
  sdk: gradio
8
  sdk_version: 3.6
9
+ app_file: run.py
10
  pinned: false
11
  ---
 
 
__pycache__/run.cpython-36.pyc ADDED
Binary file (868 Bytes). View file
 
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ https://gradio-main-build.s3.amazonaws.com/c3bec6153737855510542e8154391f328ac72606/gradio-3.6-py3-none-any.whl
run.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from difflib import Differ
2
+
3
+ import gradio as gr
4
+
5
+
6
+ def diff_texts(text1, text2):
7
+ d = Differ()
8
+ return [
9
+ (token[2:], token[0] if token[0] != " " else None)
10
+ for token in d.compare(text1, text2)
11
+ ]
12
+
13
+
14
+ demo = gr.Interface(
15
+ diff_texts,
16
+ [
17
+ gr.Textbox(
18
+ label="Initial text",
19
+ lines=3,
20
+ value="The quick brown fox jumped over the lazy dogs.",
21
+ ),
22
+ gr.Textbox(
23
+ label="Text to compare",
24
+ lines=3,
25
+ value="The fast brown fox jumps over lazy dogs.",
26
+ ),
27
+ ],
28
+ gr.HighlightedText(
29
+ label="Diff",
30
+ combine_adjacent=True,
31
+ ).style(color_map={"+": "red", "-": "green"}),
32
+ )
33
+ if __name__ == "__main__":
34
+ demo.launch()
screenshot.png ADDED