Spaces:
Sleeping
Sleeping
import gradio as gr | |
from svm_predict import predict | |
def process_sentence(sentence): | |
words, tags = predict(sentence) | |
return " ".join([f"<span style='color:green;'>{word}</span>_<span style='color:blue;'>{tag}</span>" for word, tag in zip(words, tags)]) | |
iface = gr.Interface( | |
fn=process_sentence, | |
inputs=gr.Textbox(label="Enter a sentence", lines=4), | |
outputs=gr.HTML(label="NEI tagged sentence", elem_id="output-box"), | |
css=""" | |
#input-box { | |
width: 50%; | |
height: 150px; | |
} | |
#output-box { | |
overflow-y: scroll; /* Always allow vertical scrolling */ | |
padding: 10px; | |
border-radius: 5px; | |
box-sizing: border-box; /* Ensures padding is included */ | |
white-space: pre-wrap; /* Ensure the text wraps to avoid horizontal scrolling */ | |
} | |
""", | |
live=False | |
) | |
iface.launch() |