Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'Word2VecKeyedVectors' object has no attribute 'get_vocab' #249

Closed
Earl-CS opened this issue Nov 6, 2021 · 2 comments
Closed

'Word2VecKeyedVectors' object has no attribute 'get_vocab' #249

Earl-CS opened this issue Nov 6, 2021 · 2 comments

Comments

@Earl-CS
Copy link

Earl-CS commented Nov 6, 2021

Hi!

I'm getting this error when I tried to augment a text. I used a pre-trained embedding called BioWordVec, their github repo is here:

I loaded their vector using gensim

bwv = KeyedVectors.load_word2vec_format('/Thesis/Word Embeddings/BioWordVec_PubMed_MIMICIII_d200.vec.bin', binary=True, limit=1000000)

and used it in WordsEmbAug like this

aug = naw.WordEmbsAug( model_type='word2vec', model= bwv, action="insert")

and when I run

aug_text = aug.augment(text)

I get the error 'Word2VecKeyedVectors' object has no attribute 'get_vocab'

@makcedward
Copy link
Owner

makcedward commented Nov 20, 2021

The class of "model" is custom defined class but not native gensim model class. You may simply use
aug = naw.WordEmbsAug( model_type='word2vec', model_path= '/Thesis/Word Embeddings/BioWordVec_PubMed_MIMICIII_d200.vec.bin', action="insert")

or you can load embeddings into a custom class first and passing it to augmenter

import nlpaug.model.word_embs as nmw
model = nmw.Word2vec()
model.read('/Thesis/Word Embeddings/BioWordVec_PubMed_MIMICIII_d200.vec.bin' , max_num_vector=1000000)

aug = naw.WordEmbsAug( model_type='word2vec', model= model, action="insert")

@Earl-CS
Copy link
Author

Earl-CS commented Nov 28, 2021

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants