Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from flair.data import Sentence
|
3 |
+
from flair.models import SequenceTagger
|
4 |
+
|
5 |
+
# Load your POS tagger model from Hugging Face
|
6 |
+
model_path = "onurkeles/hamshetsnag-pos-tagger"
|
7 |
+
pos_tagger = SequenceTagger.load(model_path)
|
8 |
+
|
9 |
+
def tag_pos(text):
|
10 |
+
sentence = Sentence(text)
|
11 |
+
pos_tagger.predict(sentence)
|
12 |
+
return sentence.to_tagged_string()
|
13 |
+
|
14 |
+
# Define Gradio interface for POS tagging
|
15 |
+
gradio_app = gr.Interface(
|
16 |
+
fn=tag_pos,
|
17 |
+
inputs=gr.Textbox(lines=2, placeholder="Enter a sentence here...", label="Input Sentence"),
|
18 |
+
outputs=gr.Textbox(label="Tagged Sentence"),
|
19 |
+
title="POS Tagging for Hamshetsnag",
|
20 |
+
description="This app tags parts of speech in input sentences. Cite Keleş & Günay (2024) lol."
|
21 |
+
)
|
22 |
+
|
23 |
+
if __name__ == "__main__":
|
24 |
+
gradio_app.launch()
|