cdleong commited on
Commit
49de2b2
1 Parent(s): 12dfc24

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -2
app.py CHANGED
@@ -41,6 +41,8 @@ def get_valid_epitran_mappings_list():
41
  map_path = Path(epitran.__path__[0]) / "data" / "map"
42
  map_files = map_path.glob("*.*")
43
  valid_mappings = [map_file.stem for map_file in map_files]
 
 
44
  problem_mappings = ['generic-Latn',
45
  'tur-Latn-bab',
46
  'ood-Latn-sax',
@@ -48,6 +50,7 @@ def get_valid_epitran_mappings_list():
48
  'vie-Latn-ce',
49
  'vie-Latn-no',
50
  'kaz-Cyrl-bab'] # https://github.com/dmort27/epitran/issues/98
 
51
  filtered_mappings = [mapping for mapping in valid_mappings if mapping not in problem_mappings]
52
 
53
  return filtered_mappings
@@ -66,16 +69,25 @@ if __name__ == "__main__":
66
  #st.write(valid_epitran_mappings)
67
 
68
  selected_mapping = st.selectbox("Select input language/script:", valid_epitran_mappings, index=index_of_swa_latn)
 
 
69
  description = get_lang_description_from_mapping_name(selected_mapping)
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])
76
  # st.write(f"Combined code: {combined_code}")
77
- st.info("attempting to instantiate epitran transliterator for your language/script")
78
- epi = epitran.Epitran(selected_mapping)
79
 
80
  st.info(f"transliterating `{input_text}`\n\tusing {selected_mapping}...")
81
  transliteration = epi.transliterate(input_text)
 
41
  map_path = Path(epitran.__path__[0]) / "data" / "map"
42
  map_files = map_path.glob("*.*")
43
  valid_mappings = [map_file.stem for map_file in map_files]
44
+ valid_mappings.append("cmn-Hans")
45
+
46
  problem_mappings = ['generic-Latn',
47
  'tur-Latn-bab',
48
  'ood-Latn-sax',
 
50
  'vie-Latn-ce',
51
  'vie-Latn-no',
52
  'kaz-Cyrl-bab'] # https://github.com/dmort27/epitran/issues/98
53
+
54
  filtered_mappings = [mapping for mapping in valid_mappings if mapping not in problem_mappings]
55
 
56
  return filtered_mappings
 
69
  #st.write(valid_epitran_mappings)
70
 
71
  selected_mapping = st.selectbox("Select input language/script:", valid_epitran_mappings, index=index_of_swa_latn)
72
+
73
+
74
  description = get_lang_description_from_mapping_name(selected_mapping)
75
  st.write(f"Selected input language/script: {description}")
76
 
77
 
78
+ if selected_mapping = "cmn-Hans":
79
+ st.info("Chinese requires a special dictionary. Downloading now")
80
+ epitran.download.cedict()
81
+
82
+ st.info("attempting to instantiate epitran transliterator for your language/script")
83
+ epi = epitran.Epitran(selected_mapping)
84
+
85
+
86
  input_text = st.text_area(label="Whatever you type here will be transliterated!", value="Gari langu linaloangama limejaa na mikunga")
87
 
88
  # combined_code = "-".join([iso_lang_code, iso_script_code])
89
  # st.write(f"Combined code: {combined_code}")
90
+
 
91
 
92
  st.info(f"transliterating `{input_text}`\n\tusing {selected_mapping}...")
93
  transliteration = epi.transliterate(input_text)