spr1ng commited on
Commit
60fde8d
1 Parent(s): 7ad0164

Upload folder using huggingface_hub

Browse files
Files changed (5) hide show
  1. .app.py.swp +0 -0
  2. README.md +2 -8
  3. __pycache__/app.cpython-312.pyc +0 -0
  4. app.py +55 -0
  5. flagged/log.csv +3 -0
.app.py.swp ADDED
Binary file (12.3 kB). View file
 
README.md CHANGED
@@ -1,12 +1,6 @@
1
  ---
2
- title: C1 Orders Diff
3
- emoji: 📚
4
- colorFrom: green
5
- colorTo: yellow
6
  sdk: gradio
7
  sdk_version: 4.25.0
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
+ title: c1_orders_diff
3
+ app_file: app.py
 
 
4
  sdk: gradio
5
  sdk_version: 4.25.0
 
 
6
  ---
 
 
__pycache__/app.cpython-312.pyc ADDED
Binary file (2.2 kB). View file
 
app.py ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import re
3
+
4
+ def split(lst):
5
+ return lst.split(",")
6
+
7
+ def inters(lst1, lst2):
8
+ return list(set(lst1) & set(lst2))
9
+
10
+ def diff(lst1, lst2):
11
+ return list(set(lst1) - set(lst2))
12
+
13
+ def convert(list, sign):
14
+ return [(item, sign) for item in list]
15
+
16
+ def diff_texts(text1, text2):
17
+ input1 = re.findall('АГС (.+?) ', text1)
18
+ input2 = re.findall('АГС (.+?) ', text2)
19
+
20
+ lst1 = input1 or split(text1)
21
+ lst2 = input2 or split(text2)
22
+
23
+ diff1 = convert(diff(lst1, lst2), '-')
24
+ diff2 = convert(diff(lst2, lst1), '+')
25
+ intrs = convert(inters(lst1, lst2), None)
26
+
27
+ return diff1 + diff2 + intrs
28
+
29
+ demo = gr.Interface(
30
+ diff_texts,
31
+ [
32
+ gr.Textbox(
33
+ label="Text 1",
34
+ info="Initial text",
35
+ lines=3,
36
+ #value="ЭУ063473,ЭУ063414,ТО041305",
37
+ ),
38
+ gr.Textbox(
39
+ label="Text 2",
40
+ info="Text to compare",
41
+ lines=3,
42
+ #value="ЭУ063443,ЭУ063473,ТО041384,ТО041305,ЭУ063414",
43
+ ),
44
+ ],
45
+ #"textbox",
46
+ gr.HighlightedText(
47
+ label="Diff",
48
+ combine_adjacent=True,
49
+ adjacent_separator=", ",
50
+ show_legend=True,
51
+ color_map={"+": "red", "-": "green"}),
52
+ theme=gr.themes.Base()
53
+ )
54
+
55
+ demo.launch(share=True)
flagged/log.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ name,intensity,output,flag,username,timestamp
2
+ ,0,,,,2024-04-03 11:29:22.098254
3
+ gogogo,0,"Hello, gogogo",,,2024-04-03 11:29:30.864711