cdleong commited on
Commit
0ba8db9
β€’
1 Parent(s): bba97f2

caching some stuff!

Browse files
Files changed (1) hide show
  1. app.py +13 -11
app.py CHANGED
@@ -57,6 +57,16 @@ def get_valid_epitran_mappings_list():
57
 
58
  return filtered_mappings
59
 
 
 
 
 
 
 
 
 
 
 
60
 
61
  if __name__ == "__main__":
62
 
@@ -75,17 +85,9 @@ if __name__ == "__main__":
75
 
76
  description = get_lang_description_from_mapping_name(selected_mapping)
77
  st.write(f"Selected input language/script: {description}")
78
-
79
-
80
- if selected_mapping == "cmn-Hans":
81
- st.info("Chinese requires a special dictionary. Downloading now")
82
- epitran.download.cedict()
83
-
84
- st.info("attempting to instantiate epitran transliterator for your language/script")
85
- epi = epitran.Epitran(selected_mapping)
86
-
87
-
88
-
89
  examples = defaultdict(lambda: 'Try typing some words in the language you chose, and they will be transliterated.')
90
  examples['cmn-Hans'] = 'ε€ͺεˆζœ‰ι“οΌŒι“δΈŽη₯žεŒεœ¨οΌŒι“ε°±ζ˜―η₯žγ€‚'
91
  examples['swa-Latn'] = 'Mwanzoni Kabla ulimwengu haujaumbwa alikuwepo Neno Huyo Neno alikuwa pamoja na Mungu, na Neno alikuwa Mungu.'
 
57
 
58
  return filtered_mappings
59
 
60
+ @st.cache
61
+ def get_epitran(selected_mapping):
62
+ if selected_mapping == "cmn-Hans":
63
+ st.info("Chinese requires a special dictionary. Downloading now")
64
+ epitran.download.cedict()
65
+
66
+ st.info("attempting to instantiate epitran transliterator for your language/script")
67
+ epi = epitran.Epitran(selected_mapping)
68
+ return epi
69
+
70
 
71
  if __name__ == "__main__":
72
 
 
85
 
86
  description = get_lang_description_from_mapping_name(selected_mapping)
87
  st.write(f"Selected input language/script: {description}")
88
+
89
+ epi = get_epitran(selected_mapping)
90
+
 
 
 
 
 
 
 
 
91
  examples = defaultdict(lambda: 'Try typing some words in the language you chose, and they will be transliterated.')
92
  examples['cmn-Hans'] = 'ε€ͺεˆζœ‰ι“οΌŒι“δΈŽη₯žεŒεœ¨οΌŒι“ε°±ζ˜―η₯žγ€‚'
93
  examples['swa-Latn'] = 'Mwanzoni Kabla ulimwengu haujaumbwa alikuwepo Neno Huyo Neno alikuwa pamoja na Mungu, na Neno alikuwa Mungu.'