File size: 1,157 Bytes
d31f4ce
5668b25
 
 
 
d31f4ce
 
f9b0cc9
 
 
 
0821c46
f9b0cc9
 
 
 
 
 
 
 
a90a03e
f9b0cc9
a90a03e
 
f9b0cc9
 
5668b25
 
f9b0cc9
a90a03e
c34bf05
a90a03e
 
 
f9b0cc9
 
5668b25
f9b0cc9
 
5668b25
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
38
39
40
41
import gradio as gr
from pathlib import Path


DESCRIPTION = Path("description.md").read_text(encoding='utf-8')


logic_dict = {
    'AND': '∧',
    'OR': '∨',
    'NOT': '¬',
    'XR': '⊕',
    'IMPLY': '→',
    'EQUIV': '↔',
    'ALL': '∀',
    'EXIST': '∃'
}


def logic(string: str):
    processed_string = string
    for word, symbol in logic_dict.items():
        processed_string = processed_string.replace(word, symbol)
    return processed_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=DESCRIPTION,
                    live=True)

demo.launch(share=True)