TIMAX-159
instruction
5668b25
raw history blame
No virus
1.16 kB
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)