LMartinezEXEX commited on
Commit
8783987
·
1 Parent(s): 0c56fea

Reverted change to upload .bin with different approaches, will be only using .vec extended files in HF

Browse files
Files changed (1) hide show
  1. modules/model_embbeding.py +2 -39
modules/model_embbeding.py CHANGED
@@ -91,49 +91,12 @@ class Embedding:
91
  n_components=2
92
  )
93
 
94
- model = None
95
- binary = path.endswith('.bin')
96
-
97
- # Should be enough for all .vec files
98
- try:
99
- model = KeyedVectors.load_word2vec_format(
100
  fname=path,
101
- binary=binary,
102
  limit=limit,
103
  unicode_errors='ignore'
104
  )
105
-
106
- except UnicodeDecodeError:
107
- pass #Try other way of loading
108
-
109
- # If it's a .bin Fasttext saved model
110
- if model is None and binary:
111
- print('Error during load of provided model. \
112
- Using different approaches. \
113
- The limit parameter won\'t be taken into account'
114
- )
115
-
116
- # If it's a Fasttext model
117
- try:
118
- model = load_facebook_vectors(
119
- path=path
120
- )
121
-
122
- except UnicodeDecodeError:
123
- pass
124
-
125
- if model is None:
126
- # Last chance, if it is a Word2Vec model
127
- try:
128
- model = KeyedVectors.load(
129
- fname=path
130
- )
131
-
132
- except:
133
- pass
134
-
135
- if model is None:
136
- raise Exception(f'Can\'t load {path} after multiple approaches.')
137
 
138
  # Cased Vocab
139
  cased_words = model.index_to_key
 
91
  n_components=2
92
  )
93
 
94
+ model = KeyedVectors.load_word2vec_format(
 
 
 
 
 
95
  fname=path,
96
+ binary=path.endswith('.bin'),
97
  limit=limit,
98
  unicode_errors='ignore'
99
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
 
101
  # Cased Vocab
102
  cased_words = model.index_to_key