Update fincat_utils.py
Browse files- fincat_utils.py +9 -7
fincat_utils.py
CHANGED
@@ -99,10 +99,12 @@ def bert_embedding_extract(context_text, word):
|
|
99 |
list_token_embeddings = get_bert_embeddings(tokens_tensor, segments_tensors, model)
|
100 |
word_tokens,tt,st = bert_text_preparation(word, tokenizer)
|
101 |
word_embedding_all = []
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
|
|
|
|
|
99 |
list_token_embeddings = get_bert_embeddings(tokens_tensor, segments_tensors, model)
|
100 |
word_tokens,tt,st = bert_text_preparation(word, tokenizer)
|
101 |
word_embedding_all = []
|
102 |
+
try:
|
103 |
+
for word_tk in word_tokens:
|
104 |
+
word_index = tokenized_text.index(word_tk)
|
105 |
+
word_embedding = list_token_embeddings[word_index]
|
106 |
+
word_embedding_all.append(word_embedding)
|
107 |
+
word_embedding_mean = np.array(word_embedding_all).mean(axis=0)
|
108 |
+
return word_embedding_mean
|
109 |
+
except:
|
110 |
+
return ['None']
|