Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| from NDETCStemmer import NDETCStemmer | |
| num_text_process_limit = 100 | |
| markdown_top_info = """ | |
| # [NDETCStemmer](https://huggingface.co/kaenova/NDETCStemmer) spaces | |
| Easily use the model with huggingface π€ and gradio interface! | |
| Call by API is also available. Check the bottom of the page on 'Use via API π' | |
| """ | |
| stemmer = NDETCStemmer() | |
| process_counter = 0 | |
| def process_single_text(text_input: "str"): | |
| # Split input | |
| if text_input.strip() == "": | |
| return "" | |
| results = stemmer.stem(text_input) | |
| # Logging | |
| global process_counter | |
| process_counter = process_counter + 1 | |
| print(f"INFO: Number of processed text {process_counter}") | |
| return results | |
| with gr.Blocks() as demo: | |
| gr.Markdown(markdown_top_info) | |
| # Single Input | |
| with gr.Column(): | |
| input_text = gr.Textbox( | |
| label="Input Text", | |
| info=f"Text to stem.", | |
| lines=5, | |
| value="""bibirnya memerah tangannya jadi selengket madu dan ia berkata 'Boleh saya memerah lembu ini?'""", | |
| ) | |
| single_text_button = gr.Button("Stem!") | |
| results_text = gr.Textbox( | |
| label=f"Result", | |
| interactive=False, | |
| ) | |
| single_text_button.click( | |
| process_single_text, | |
| inputs=[input_text], | |
| outputs=[results_text], | |
| api_name="process" | |
| ) | |
| if __name__ == "__main__": | |
| demo.queue(concurrency_count=100) | |
| demo.launch() | |