gilesitorr commited on
Commit
1f738ee
·
1 Parent(s): 7861736

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -1,5 +1,6 @@
1
  import streamlit as st
2
  import json
 
3
  from thefuzz import fuzz
4
  from itertools import combinations
5
  from keras_transformer import get_model, decode
@@ -121,16 +122,15 @@ def translate(oracion, model):
121
  # MAIN APP
122
  path_dict = 'https://huggingface.co/spaces/gilesitorr/Nahuatl2Spanish/raw/main/Dictionaries/'
123
 
124
- import json
125
- with open(path_dict+'uncased_tokens_pretrained.json', 'r') as f:
126
- source_token_dict = json.load(f)
127
 
128
- with open(path_dict+'uncased_tokens_inv_pretrained.json', 'r') as f:
129
- target_token_dict_inv = json.load(f)
130
- target_token_dict_inv = {int(k): v for k,v in target_token_dict_inv.items()}
131
 
132
- with open(path_dict+'nah_es.json', 'b') as f:
133
- dictionary = json.load(f)
134
 
135
  model = get_model(
136
  token_num = max(len(source_token_dict),len(target_token_dict)),
 
1
  import streamlit as st
2
  import json
3
+ from urllib.request import urlopen
4
  from thefuzz import fuzz
5
  from itertools import combinations
6
  from keras_transformer import get_model, decode
 
122
  # MAIN APP
123
  path_dict = 'https://huggingface.co/spaces/gilesitorr/Nahuatl2Spanish/raw/main/Dictionaries/'
124
 
125
+ response = urlopen(path_dict+'uncased_tokens_pretrained.json')
126
+ source_token_dict = json.loads(response.read())
 
127
 
128
+ response = urlopen(path_dict+'uncased_tokens_inv_pretrained.json')
129
+ target_token_dict_inv = json.loads(response.read())
130
+ target_token_dict_inv = {int(k): v for k,v in target_token_dict_inv.items()}
131
 
132
+ response = urlopen(path_dict+'nah_es.json')
133
+ dictionary = json.loads(response.read())
134
 
135
  model = get_model(
136
  token_num = max(len(source_token_dict),len(target_token_dict)),