TIMAX-159 commited on
Commit
f9b0cc9
β€’
1 Parent(s): d31f4ce

translator

Browse files
Files changed (1) hide show
  1. app.py +30 -4
app.py CHANGED
@@ -1,7 +1,33 @@
1
  import gradio as gr
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
 
 
 
3
 
4
+ logic_dict = {
5
+ 'AND': '∧',
6
+ 'OR': '∨',
7
+ 'NOT': 'Β¬',
8
+ 'IMPLY': 'β†’',
9
+ 'EQUIV': '↔',
10
+ 'ALL': 'βˆ€',
11
+ 'EXIST': 'βˆƒ'
12
+ }
13
+
14
+
15
+ def logic(string: str):
16
+ for word, symbol in logic_dict.items():
17
+ string = string.replace(word, symbol)
18
+ return string
19
+
20
+
21
+ demo = gr.Interface(fn=logic,
22
+ inputs="text", outputs="text",
23
+ examples=[
24
+ 'ALLx. Student(x) IMPLY Smart(x)',
25
+ 'EXISTx. TShirt(x) AND Buy(Adam, x)',
26
+ 'ALLx. Animal(x) AND Fluffy(x) IMPLY Rabbit(x) OR Sheep(x)'
27
+ ],
28
+ title="Logic Translator",
29
+ description="∧:AND, ∨:OR, Β¬:NOT, β†’:IMPLY, ↔:EQUIV, βˆ€:ALL, βˆƒ:EXIST",
30
+ live=True)
31
+
32
+ demo.launch(share=True)
33
+