Spaces:
Runtime error
Runtime error
Bugfixing gradio app. Removing linebreaks is necessary.
Browse files
app.py
CHANGED
@@ -46,6 +46,7 @@ def find_model(language: str):
|
|
46 |
|
47 |
|
48 |
def predict_lang(text: str) -> str:
|
|
|
49 |
predictions = lang_model.predict(text, k=1) # returns top 2 matching languages
|
50 |
language = predictions[0][0] # returns top 2 matching languages
|
51 |
language = re.sub(r'__label__', '', language) # returns top 2 matching languages
|
@@ -81,11 +82,11 @@ def topic_modeling(text: str, threshold: float) -> [List[str], str]:
|
|
81 |
|
82 |
with gr.Blocks() as iface:
|
83 |
gr.Markdown("# Topic Modeling")
|
84 |
-
gr.Markdown("Enter a
|
85 |
|
86 |
with gr.Row():
|
87 |
with gr.Column():
|
88 |
-
input_text = gr.Textbox(lines=10, placeholder="Enter
|
89 |
submit_button = gr.Button("Submit")
|
90 |
threshold_slider = gr.Slider(minimum=0.0, maximum=1.0, step=0.01, label="Score Threshold", value=0.0)
|
91 |
language_text = gr.Textbox(lines=1, placeholder="Detected language will be shown here...",
|
@@ -96,4 +97,4 @@ with gr.Blocks() as iface:
|
|
96 |
submit_button.click(topic_modeling, inputs=[input_text, threshold_slider], outputs=[output_data, language_text])
|
97 |
|
98 |
# Launch the app
|
99 |
-
iface.launch()
|
|
|
46 |
|
47 |
|
48 |
def predict_lang(text: str) -> str:
|
49 |
+
text = re.sub(r'\n', '', text) # Remove linebreaks because fasttext cannot process that otherwise
|
50 |
predictions = lang_model.predict(text, k=1) # returns top 2 matching languages
|
51 |
language = predictions[0][0] # returns top 2 matching languages
|
52 |
language = re.sub(r'__label__', '', language) # returns top 2 matching languages
|
|
|
82 |
|
83 |
with gr.Blocks() as iface:
|
84 |
gr.Markdown("# Topic Modeling")
|
85 |
+
gr.Markdown("Enter a document and get each topic along with its score.")
|
86 |
|
87 |
with gr.Row():
|
88 |
with gr.Column():
|
89 |
+
input_text = gr.Textbox(lines=10, placeholder="Enter a document")
|
90 |
submit_button = gr.Button("Submit")
|
91 |
threshold_slider = gr.Slider(minimum=0.0, maximum=1.0, step=0.01, label="Score Threshold", value=0.0)
|
92 |
language_text = gr.Textbox(lines=1, placeholder="Detected language will be shown here...",
|
|
|
97 |
submit_button.click(topic_modeling, inputs=[input_text, threshold_slider], outputs=[output_data, language_text])
|
98 |
|
99 |
# Launch the app
|
100 |
+
iface.launch(share=True)
|