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 |
+
|