makcedward / nlpaug

Data augmentation for NLP
https://makcedward.github.io/
MIT License
4.45k stars 463 forks source link

SynonymAug error #220

Closed Tanu911 closed 2 years ago

Tanu911 commented 3 years ago

I am getting this error while using synonymAug. Please help ASAP

BadZipFile Traceback (most recent call last)

in 1 import nlpaug.augmenter.word as naw ----> 2 aug = naw.SynonymAug() ~\Anaconda3\lib\site-packages\nlpaug\augmenter\word\synonym.py in __init__(self, aug_src, model_path, name, aug_min, aug_max, aug_p, lang, stopwords, tokenizer, reverse_tokenizer, stopwords_regex, force_reload, verbose) 62 self.model_path = model_path 63 self.lang = lang ---> 64 self.model = self.get_model(aug_src, lang, model_path, force_reload) 65 66 def skip_aug(self, token_idxes, tokens): ~\Anaconda3\lib\site-packages\nlpaug\augmenter\word\synonym.py in get_model(cls, aug_src, lang, dict_path, force_reload) 159 def get_model(cls, aug_src, lang, dict_path, force_reload): 160 if aug_src == 'wordnet': --> 161 return nmw.WordNet(lang=lang, is_synonym=True) 162 elif aug_src == 'ppdb': 163 return init_ppdb_model(dict_path=dict_path, force_reload=force_reload) ~\Anaconda3\lib\site-packages\nlpaug\model\word_dict\wordnet.py in __init__(self, lang, is_synonym) 26 wordnet.synsets('computer') 27 # Check whether POS package is downloaded ---> 28 nltk.pos_tag('computer') 29 except LookupError: 30 nltk.download('wordnet') ~\Anaconda3\lib\site-packages\nltk\tag\__init__.py in pos_tag(tokens, tagset, lang) 162 :rtype: list(tuple(str, str)) 163 """ --> 164 tagger = _get_tagger(lang) 165 return _pos_tag(tokens, tagset, tagger, lang) 166 ~\Anaconda3\lib\site-packages\nltk\tag\__init__.py in _get_tagger(lang) 104 tagger.load(ap_russian_model_loc) 105 else: --> 106 tagger = PerceptronTagger() 107 return tagger 108 ~\Anaconda3\lib\site-packages\nltk\tag\perceptron.py in __init__(self, load) 166 if load: 167 AP_MODEL_LOC = "file:" + str( --> 168 find("taggers/averaged_perceptron_tagger/" + PICKLE) 169 ) 170 self.load(AP_MODEL_LOC) ~\Anaconda3\lib\site-packages\nltk\data.py in find(resource_name, paths) 553 modified_name = "/".join(pieces[:i] + [pieces[i] + ".zip"] + pieces[i:]) 554 try: --> 555 return find(modified_name, paths) 556 except LookupError: 557 pass ~\Anaconda3\lib\site-packages\nltk\data.py in find(resource_name, paths) 540 if os.path.exists(p): 541 try: --> 542 return ZipFilePathPointer(p, zipentry) 543 except IOError: 544 # resource not in zipfile ~\Anaconda3\lib\site-packages\nltk\compat.py in _decorator(*args, **kwargs) 39 def _decorator(*args, **kwargs): 40 args = (args[0], add_py3_data(args[1])) + args[2:] ---> 41 return init_func(*args, **kwargs) 42 43 return wraps(init_func)(_decorator) ~\Anaconda3\lib\site-packages\nltk\data.py in __init__(self, zipfile, entry) 392 """ 393 if isinstance(zipfile, str): --> 394 zipfile = OpenOnDemandZipFile(os.path.abspath(zipfile)) 395 396 # Check that the entry exists: ~\Anaconda3\lib\site-packages\nltk\compat.py in _decorator(*args, **kwargs) 39 def _decorator(*args, **kwargs): 40 args = (args[0], add_py3_data(args[1])) + args[2:] ---> 41 return init_func(*args, **kwargs) 42 43 return wraps(init_func)(_decorator) ~\Anaconda3\lib\site-packages\nltk\data.py in __init__(self, filename) 932 if not isinstance(filename, str): 933 raise TypeError("ReopenableZipFile filename must be a string") --> 934 zipfile.ZipFile.__init__(self, filename) 935 assert self.filename == filename 936 self.close() ~\Anaconda3\lib\zipfile.py in __init__(self, file, mode, compression, allowZip64, compresslevel, strict_timestamps) 1267 try: 1268 if mode == 'r': -> 1269 self._RealGetContents() 1270 elif mode in ('w', 'x'): 1271 # set the modified flag so central directory gets written ~\Anaconda3\lib\zipfile.py in _RealGetContents(self) 1334 raise BadZipFile("File is not a zip file") 1335 if not endrec: -> 1336 raise BadZipFile("File is not a zip file") 1337 if self.debug > 1: 1338 print(endrec) BadZipFile: File is not a zip file
makcedward commented 2 years ago

It should relate NLTK version. What are your NLTK and nlpaug version?

Searched a solution. See whether it solved https://stackoverflow.com/questions/28122980/bad-zip-file-error-in-pos-tagging-in-nltk-in-python