File size: 1,138 Bytes
d31f4ce
 
 
f9b0cc9
 
 
 
0821c46
f9b0cc9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2263680
0821c46
 
f9b0cc9
 
0821c46
f9b0cc9
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import gradio as gr


logic_dict = {
    'AND': '∧',
    'OR': '∨',
    'NOT': 'Β¬',
    'XR': 'βŠ•',
    'IMPLY': 'β†’',
    'EQUIV': '↔',
    'ALL': 'βˆ€',
    'EXIST': 'βˆƒ'
}


def logic(string: str):
    for word, symbol in logic_dict.items():
        string = string.replace(word, symbol)
    return string


demo = gr.Interface(fn=logic, 
                    inputs="text", outputs="text", 
                    examples=[
                        'ALLx. Student(x) IMPLY Smart(x)',
                        'EXISTx. TShirt(x) AND Buy(Adam, x)',
                        'ALLx. (Animal(x) AND Fluffy(x)) IMPLY (Rabbit(x) OR Sheep(x))',
                        '(GoDowntown(James) AND NOTCarry(James, Bag)) EQUIV Buy(James, Book)',
                        'ALLx. Project(x) IMPLY (WrittenIn(x, Python) XR WrittenIn(x, C++))'
                    ],
                    title="Logic Translator",
                    description="Type English for logic symbols!     \n                                ∧:AND, ∨:OR, Β¬:NOT, βŠ•:XR, β†’:IMPLY, ↔:EQUIV, βˆ€:ALL, βˆƒ:EXIST",
                    live=True)

demo.launch(share=True)