Merge pull request #546 from microsoft/copilot/fix-c7041bba-c360-467e-8d43-4a01b9cf0197
Fix AttributeError: 'GloVe' object has no attribute 'get_stoi' in EmbeddingsPyTorch.ipynb
This commit is contained in:
commit
0581b4546e
|
|
@ -30,7 +30,11 @@ def encode(x,voc=None,unk=0,tokenizer=tokenizer):
|
|||
if v in stoi_hash.keys():
|
||||
stoi = stoi_hash[v]
|
||||
else:
|
||||
stoi = v.get_stoi()
|
||||
# Handle both vocab.vocab objects (with get_stoi() method) and GloVe objects (with stoi attribute)
|
||||
if hasattr(v, 'get_stoi'):
|
||||
stoi = v.get_stoi()
|
||||
else:
|
||||
stoi = v.stoi
|
||||
stoi_hash[v]=stoi
|
||||
return [stoi.get(s,unk) for s in tokenizer(x)]
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,11 @@ def encode(x,voc=None,unk=0,tokenizer=tokenizer):
|
|||
if v in stoi_hash.keys():
|
||||
stoi = stoi_hash[v]
|
||||
else:
|
||||
stoi = v.get_stoi()
|
||||
# Handle both vocab.vocab objects (with get_stoi() method) and GloVe objects (with stoi attribute)
|
||||
if hasattr(v, 'get_stoi'):
|
||||
stoi = v.get_stoi()
|
||||
else:
|
||||
stoi = v.stoi
|
||||
stoi_hash[v]=stoi
|
||||
return [stoi.get(s,unk) for s in tokenizer(x)]
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,11 @@ def encode(x,voc=None,unk=0,tokenizer=tokenizer):
|
|||
if v in stoi_hash.keys():
|
||||
stoi = stoi_hash[v]
|
||||
else:
|
||||
stoi = v.get_stoi()
|
||||
# Handle both vocab.vocab objects (with get_stoi() method) and GloVe objects (with stoi attribute)
|
||||
if hasattr(v, 'get_stoi'):
|
||||
stoi = v.get_stoi()
|
||||
else:
|
||||
stoi = v.stoi
|
||||
stoi_hash[v]=stoi
|
||||
return [stoi.get(s,unk) for s in tokenizer(x)]
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,11 @@ def encode(x,voc=None,unk=0,tokenizer=tokenizer):
|
|||
if v in stoi_hash.keys():
|
||||
stoi = stoi_hash[v]
|
||||
else:
|
||||
stoi = v.get_stoi()
|
||||
# Handle both vocab.vocab objects (with get_stoi() method) and GloVe objects (with stoi attribute)
|
||||
if hasattr(v, 'get_stoi'):
|
||||
stoi = v.get_stoi()
|
||||
else:
|
||||
stoi = v.stoi
|
||||
stoi_hash[v]=stoi
|
||||
return [stoi.get(s,unk) for s in tokenizer(x)]
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue