Update app.py
Browse files
app.py
CHANGED
|
@@ -62,15 +62,15 @@ def detect_language(input_text: str, used_libraries: list[str]) -> tuple[str, st
|
|
| 62 |
if not input_text or not used_libraries:
|
| 63 |
return [['No input text or library selected', 'Please provide input text and/or select a detection library']]
|
| 64 |
if 'langdetect' in used_libraries:
|
| 65 |
-
detections.append(detectinstance.langdetect())
|
| 66 |
if 'langid' in used_libraries:
|
| 67 |
-
detections.append(detectinstance.langid())
|
| 68 |
if 'lingua-py' in used_libraries:
|
| 69 |
-
detections.append(detectinstance.lingua())
|
| 70 |
if 'fasttextlangdetect' in used_libraries:
|
| 71 |
-
detections.append(detectinstance.fasttextlangdetect())
|
| 72 |
if 'fastlangdetect' in used_libraries:
|
| 73 |
-
detections.append(detectinstance.fastlangdetect())
|
| 74 |
print(detections)
|
| 75 |
return detections
|
| 76 |
|
|
@@ -81,11 +81,11 @@ with gr.Blocks() as interface:
|
|
| 81 |
with gr.Row(variant="compact"):
|
| 82 |
used_libraries = gr.CheckboxGroup(choices=libraries, value=libraries, label="Detection libraries", show_select_all=True)
|
| 83 |
dataframe = gr.Dataframe(
|
| 84 |
-
headers=["Language code", "Score"],
|
| 85 |
-
datatype=["str", "number"],
|
| 86 |
type='array',
|
| 87 |
row_count=len(libraries),
|
| 88 |
-
column_count=
|
| 89 |
column_limits=(2, 4),
|
| 90 |
label='Language detection dataframe'
|
| 91 |
)
|
|
|
|
| 62 |
if not input_text or not used_libraries:
|
| 63 |
return [['No input text or library selected', 'Please provide input text and/or select a detection library']]
|
| 64 |
if 'langdetect' in used_libraries:
|
| 65 |
+
detections.append(['langdetect'] + detectinstance.langdetect())
|
| 66 |
if 'langid' in used_libraries:
|
| 67 |
+
detections.append(['langid'] + detectinstance.langid())
|
| 68 |
if 'lingua-py' in used_libraries:
|
| 69 |
+
detections.append(['lingua-py'] + detectinstance.lingua())
|
| 70 |
if 'fasttextlangdetect' in used_libraries:
|
| 71 |
+
detections.append(['fasttextlangdetect'] + detectinstance.fasttextlangdetect())
|
| 72 |
if 'fastlangdetect' in used_libraries:
|
| 73 |
+
detections.append(['fastlangdetect'] + detectinstance.fastlangdetect())
|
| 74 |
print(detections)
|
| 75 |
return detections
|
| 76 |
|
|
|
|
| 81 |
with gr.Row(variant="compact"):
|
| 82 |
used_libraries = gr.CheckboxGroup(choices=libraries, value=libraries, label="Detection libraries", show_select_all=True)
|
| 83 |
dataframe = gr.Dataframe(
|
| 84 |
+
headers=["Library", "Language code", "Score"],
|
| 85 |
+
datatype=["str", "str", "number"],
|
| 86 |
type='array',
|
| 87 |
row_count=len(libraries),
|
| 88 |
+
column_count=3,
|
| 89 |
column_limits=(2, 4),
|
| 90 |
label='Language detection dataframe'
|
| 91 |
)
|