Spaces:
Runtime error
Runtime error
TIMAX-159
commited on
Commit
Β·
f9b0cc9
1
Parent(s):
d31f4ce
translator
Browse files
app.py
CHANGED
@@ -1,7 +1,33 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
def greet(name):
|
4 |
-
return "Hello " + name + "!!"
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
|