cdleong commited on
Commit
24c5e5a
1 Parent(s): ed67811

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -27
app.py CHANGED
@@ -15,24 +15,26 @@ def get_lang_description_from_mapping_name(string_to_check):
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():
@@ -68,18 +70,6 @@ if __name__ == "__main__":
68
  st.write(f"Selected input language/script: {description}")
69
 
70
 
71
- # iso_lang_code = st.text_input(
72
- # label="Three-letter ISO-639-3 (https://iso639-3.sil.org/) language code",
73
- # value="swa"
74
- # )
75
- # st.write(f"iso code is {iso_lang_code}")
76
- #
77
- # iso_script_code = st.text_input(
78
- # label="ISO 15924 (https://unicode.org/iso15924/iso15924-codes.html) script code, e.g. 'Latn' for Latin script, 'Hans' for Chinese script, etc.",
79
- # value="Latn"
80
- # )
81
- # st.write(f'iso code is {iso_script_code}')
82
-
83
  input_text = st.text_area(label="Whatever you type here will be transliterated!", value="Gari langu linaloangama limejaa na mikunga")
84
 
85
  # combined_code = "-".join([iso_lang_code, iso_script_code])
 
15
  return None
16
 
17
  substrings = string_to_check.split("-")
18
+ substrings = substrings[:2] # first two
19
  string_to_check = "-".join(substrings)
20
 
21
+
22
+
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
+ if substrings[-1] == "red":
36
+ description = description + " (reduced)"
37
+ return description
 
 
 
 
 
 
 
 
 
 
38
 
39
 
40
  def get_valid_epitran_mappings_list():
 
70
  st.write(f"Selected input language/script: {description}")
71
 
72
 
 
 
 
 
 
 
 
 
 
 
 
 
73
  input_text = st.text_area(label="Whatever you type here will be transliterated!", value="Gari langu linaloangama limejaa na mikunga")
74
 
75
  # combined_code = "-".join([iso_lang_code, iso_script_code])