mirror of
https://github.com/QData/TextAttack.git
synced 2021-10-13 00:05:06 +03:00
add kuleshov recipe; rename attack_methods --> search_methods
This commit is contained in:
@@ -48,4 +48,13 @@ class WordEmbedding:
|
||||
self.cos_sim_mat = {}
|
||||
|
||||
def __getitem__(self, index):
|
||||
""" Gets a word embedding by word or ID.
|
||||
|
||||
If word or ID not found, returns None.
|
||||
"""
|
||||
if isinstance(index, str):
|
||||
try:
|
||||
index = self.word2index[index]
|
||||
except KeyError:
|
||||
return None
|
||||
return self.embeddings[index]
|
||||
Reference in New Issue
Block a user