Spaces:
Running
Running
| import gradio as gr | |
| import requests | |
| API_URL = "https://kazakh-stemmer-590833642796.europe-west1.run.app/demo/stem/batch" | |
| def stem(text): | |
| words = [w for w in text.replace("\n", " ").split() if w] | |
| if not words: | |
| return "Введите хотя бы одно слово." | |
| r = requests.post(API_URL, json={"words": words[:50]}, timeout=15) | |
| r.raise_for_status() | |
| rows = r.json() | |
| return "\n".join(f"{x['word']} → {x['stem']} ({x['confidence']})" for x in rows) | |
| demo = gr.Interface( | |
| fn=stem, | |
| inputs=gr.Textbox(lines=4, label="Казахский текст / Kazakh words", | |
| placeholder="балаларымызда кітабым қаладағы"), | |
| outputs=gr.Textbox(label="Корни / Stems"), | |
| title="Kazakh Stemmer", | |
| description="Morphological stemmer/lemmatizer for Kazakh (Turkic, agglutinative). " | |
| "78% exact-match on UD Kazakh KTB, zero over-stemming (Paice OI=0).", | |
| ) | |
| demo.launch() |