Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -7,7 +7,7 @@ from operator import itemgetter
|
|
7 |
# TODO: reverse transliterate?
|
8 |
|
9 |
|
10 |
-
def get_lang_description_from_mapping_name(string_to_check):
|
11 |
if "generic-Latn" == string_to_check:
|
12 |
return "Generic Latin Script"
|
13 |
|
@@ -15,28 +15,24 @@ def get_lang_description_from_mapping_name(string_to_check):
|
|
15 |
return None
|
16 |
|
17 |
substrings = string_to_check.split("-")
|
18 |
-
substrings = substrings[
|
19 |
-
print(substrings)
|
20 |
string_to_check = "-".join(substrings)
|
21 |
|
22 |
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
description = description + " (reduced)"
|
38 |
-
return description
|
39 |
-
|
40 |
|
41 |
|
42 |
def get_valid_epitran_mappings_list():
|
@@ -62,11 +58,12 @@ if __name__ == "__main__":
|
|
62 |
st.write("Epitran is a library and tool for transliterating orthographic text as IPA (International Phonetic Alphabet), by Mortensen, David R. and Dalmia, Siddharth and Littell, Patrick.")
|
63 |
|
64 |
valid_epitran_mappings = get_valid_epitran_mappings_list()
|
|
|
65 |
st.write(f"It supports converting many writing sytems to IPA symbols, including approximately {len(valid_epitran_mappings)} languages/scripts, listed below:")
|
66 |
|
67 |
#st.write(valid_epitran_mappings)
|
68 |
|
69 |
-
selected_mapping = st.selectbox("Select input language/script:", valid_epitran_mappings)
|
70 |
description = get_lang_description_from_mapping_name(selected_mapping)
|
71 |
st.write(f"Selected input language/script: {description}")
|
72 |
|
|
|
7 |
# TODO: reverse transliterate?
|
8 |
|
9 |
|
10 |
+
def get_lang_description_from_mapping_name(string_to_check):
|
11 |
if "generic-Latn" == string_to_check:
|
12 |
return "Generic Latin Script"
|
13 |
|
|
|
15 |
return None
|
16 |
|
17 |
substrings = string_to_check.split("-")
|
18 |
+
substrings = substrings[0, 1] # remove the last one
|
|
|
19 |
string_to_check = "-".join(substrings)
|
20 |
|
21 |
|
22 |
+
try:
|
23 |
+
description = None
|
24 |
+
lang = langcodes.get(string_to_check)
|
25 |
+
if lang:
|
26 |
+
items = []
|
27 |
+
for key, value in lang.describe().items():
|
28 |
+
if key == "language":
|
29 |
+
iso_code = lang.to_alpha3()
|
30 |
+
value = f"[{value}](https://iso639-3.sil.org/code/{iso_code})"
|
31 |
+
items.append(f"{key}: {value}")
|
32 |
+
|
33 |
+
|
34 |
+
description = ", ".join(items)
|
35 |
+
return description
|
|
|
|
|
|
|
36 |
|
37 |
|
38 |
def get_valid_epitran_mappings_list():
|
|
|
58 |
st.write("Epitran is a library and tool for transliterating orthographic text as IPA (International Phonetic Alphabet), by Mortensen, David R. and Dalmia, Siddharth and Littell, Patrick.")
|
59 |
|
60 |
valid_epitran_mappings = get_valid_epitran_mappings_list()
|
61 |
+
index_of_swa_latn = valid_epitran_mappings .index("swa-Latn")
|
62 |
st.write(f"It supports converting many writing sytems to IPA symbols, including approximately {len(valid_epitran_mappings)} languages/scripts, listed below:")
|
63 |
|
64 |
#st.write(valid_epitran_mappings)
|
65 |
|
66 |
+
selected_mapping = st.selectbox("Select input language/script:", valid_epitran_mappings, index=index_of_swa_latn)
|
67 |
description = get_lang_description_from_mapping_name(selected_mapping)
|
68 |
st.write(f"Selected input language/script: {description}")
|
69 |
|