Update app.py
Browse files
app.py
CHANGED
|
@@ -32,7 +32,7 @@ def timer(func):
|
|
| 32 |
return translate
|
| 33 |
|
| 34 |
@timer
|
| 35 |
-
def detect_language(input_text: str) -> tuple[str, str]:
|
| 36 |
"""
|
| 37 |
Detects the input text from the source language to the target language using a specified model.
|
| 38 |
|
|
@@ -50,6 +50,7 @@ def detect_language(input_text: str) -> tuple[str, str]:
|
|
| 50 |
"""
|
| 51 |
from langdetect import detect, detect_langs
|
| 52 |
from langdetect import DetectorFactory
|
|
|
|
| 53 |
DetectorFactory.seed = 0
|
| 54 |
langcode = detect(input_text)
|
| 55 |
langecode_probabilities: list[Language] = detect_langs(input_text)
|
|
@@ -63,10 +64,10 @@ with gr.Blocks() as interface:
|
|
| 63 |
detected_text = gr.Textbox(label="Translated text:", placeholder="Display field for translation", interactive=False, buttons=["copy"], lines=1)
|
| 64 |
confidence = gr.Textbox(label="Confidence:", placeholder="Display field for confidence score", interactive=False, buttons=["copy"], lines=1)
|
| 65 |
execution_time = gr.Textbox(label="Execution time:", placeholder="Display field for execution time", interactive=False, lines=1)
|
| 66 |
-
gr.CheckboxGroup(choices=["langdetect", "X", "XX"], label="Detection libraries", info="Detection libraries")
|
| 67 |
input_text.submit(
|
| 68 |
fn=detect_language,
|
| 69 |
-
inputs=[input_text],
|
| 70 |
outputs=[detected_text, confidence, execution_time]
|
| 71 |
)
|
| 72 |
if __name__ == "__main__":
|
|
|
|
| 32 |
return translate
|
| 33 |
|
| 34 |
@timer
|
| 35 |
+
def detect_language(input_text: str, used_libraries: list[str]) -> tuple[str, str]:
|
| 36 |
"""
|
| 37 |
Detects the input text from the source language to the target language using a specified model.
|
| 38 |
|
|
|
|
| 50 |
"""
|
| 51 |
from langdetect import detect, detect_langs
|
| 52 |
from langdetect import DetectorFactory
|
| 53 |
+
print(used_libraries)
|
| 54 |
DetectorFactory.seed = 0
|
| 55 |
langcode = detect(input_text)
|
| 56 |
langecode_probabilities: list[Language] = detect_langs(input_text)
|
|
|
|
| 64 |
detected_text = gr.Textbox(label="Translated text:", placeholder="Display field for translation", interactive=False, buttons=["copy"], lines=1)
|
| 65 |
confidence = gr.Textbox(label="Confidence:", placeholder="Display field for confidence score", interactive=False, buttons=["copy"], lines=1)
|
| 66 |
execution_time = gr.Textbox(label="Execution time:", placeholder="Display field for execution time", interactive=False, lines=1)
|
| 67 |
+
used_libraries = gr.CheckboxGroup(choices=["langdetect", "X", "XX"], label="Detection libraries", info="Detection libraries")
|
| 68 |
input_text.submit(
|
| 69 |
fn=detect_language,
|
| 70 |
+
inputs=[input_text, used_libraries],
|
| 71 |
outputs=[detected_text, confidence, execution_time]
|
| 72 |
)
|
| 73 |
if __name__ == "__main__":
|