Update app.py
Browse files
app.py
CHANGED
|
@@ -52,8 +52,8 @@ def detect_language(input_text: str, used_libraries: list[str]) -> tuple[str, st
|
|
| 52 |
listtoappend = [langcode, confidence_score]
|
| 53 |
detections.append(listtoappend)
|
| 54 |
if 'langid' in used_libraries:
|
| 55 |
-
|
| 56 |
-
|
| 57 |
detections.append(listtoappend)
|
| 58 |
print(detections)
|
| 59 |
return detections
|
|
@@ -63,7 +63,7 @@ with gr.Blocks() as interface:
|
|
| 63 |
input_text = gr.Textbox(label="Enter text to detect:", placeholder="Type/copy text here, maximum 512 characters",
|
| 64 |
autofocus=True, submit_btn='Detect Language', max_length=512)
|
| 65 |
with gr.Row(variant="compact"):
|
| 66 |
-
used_libraries = gr.CheckboxGroup(choices=libraries, value=libraries, label="Detection libraries",
|
| 67 |
dataframe = gr.Dataframe(
|
| 68 |
headers=["Language code", "Score"],
|
| 69 |
datatype=["str", "float"], # type: array
|
|
|
|
| 52 |
listtoappend = [langcode, confidence_score]
|
| 53 |
detections.append(listtoappend)
|
| 54 |
if 'langid' in used_libraries:
|
| 55 |
+
identifier = LanguageIdentifier.from_modelstring(string=model, norm_probs=False)
|
| 56 |
+
result: list[str, float] = list(identifier.classify(input_text))
|
| 57 |
detections.append(listtoappend)
|
| 58 |
print(detections)
|
| 59 |
return detections
|
|
|
|
| 63 |
input_text = gr.Textbox(label="Enter text to detect:", placeholder="Type/copy text here, maximum 512 characters",
|
| 64 |
autofocus=True, submit_btn='Detect Language', max_length=512)
|
| 65 |
with gr.Row(variant="compact"):
|
| 66 |
+
used_libraries = gr.CheckboxGroup(choices=libraries, value=libraries, label="Detection libraries", show_select_all=True)
|
| 67 |
dataframe = gr.Dataframe(
|
| 68 |
headers=["Language code", "Score"],
|
| 69 |
datatype=["str", "float"], # type: array
|