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

File not found in /model/char/keyboard/en.json #101

Closed
ljvmiranda921 opened this issue Feb 17, 2020 · 7 comments
Closed

File not found in /model/char/keyboard/en.json #101

ljvmiranda921 opened this issue Feb 17, 2020 · 7 comments

Comments

@ljvmiranda921
Copy link

ljvmiranda921 commented Feb 17, 2020

Hello! I'm encountering this error when using KeyboardAug:

Minimum Working Environment

import nlpaug.augmenter.char as nac
aug = nac.KeyboardAug()
aug.augment("hello world")

Exception

FileNotFoundError                         Traceback (most recent call last)
<ipython-input-24-c96cc55b7113> in <module>
----> 1 augment(3, nac.KeyboardAug())

~/anaconda3/lib/python3.6/site-packages/nlpaug/augmenter/char/keyboard.py in __init__(self, name, aug_char_min, aug_char_max, aug_char_p, aug_word_p, aug_word_min, aug_word_max, stopwords, tokenizer, reverse_tokenizer, special_char, numeric, upper_case, lang, verbose, stopwords_regex)
     53         self.upper_case = upper_case
     54         self.lang = lang
---> 55         self.model = self.get_model(special_char, numeric, upper_case, lang)
     56 
     57     def skip_aug(self, token_idxes, tokens):

~/anaconda3/lib/python3.6/site-packages/nlpaug/augmenter/char/keyboard.py in get_model(cls, special_char, numeric, upper_case, lang)
     99     @classmethod
    100     def get_model(cls, special_char=True, numeric=True, upper_case=True, lang="en"):
--> 101         return nmc.Keyboard(special_char=special_char, numeric=numeric, upper_case=upper_case, lang=lang)

~/anaconda3/lib/python3.6/site-packages/nlpaug/model/char/keyboard.py in __init__(self, special_char, numeric, upper_case, cache, lang)
     18         self.lang = lang
     19         self.model = self.get_model(
---> 20             model_dir=self.model_dir, special_char=special_char, numeric=numeric, upper_case=upper_case, lang=lang)
     21 
     22     def predict(self, data):

~/anaconda3/lib/python3.6/site-packages/nlpaug/model/char/keyboard.py in get_model(cls, model_dir, special_char, numeric, upper_case, lang)
     31 
     32         model_path = os.path.join(model_dir, lang+'.json')
---> 33         with open(model_path, encoding="utf8") as f:
     34             mapping = json.load(f)
     35 

FileNotFoundError: [Errno 2] No such file or directory: '/home/ljvm/anaconda3/lib/python3.6/site-packages/nlpaug/model/char/../../../model/char/keyboard/en.json'

Thoughts

  • I think that the paths here ../../../ becomes different when running nlpaug as a package.

Thank you!

@ljvmiranda921
Copy link
Author

I think it's fine to just ask for a model_dir parameter when initializing Keyboard aug and just let the users download en.json. This can be handled properly (perhaps) by incorporating the download step in your DownloadUtils

@makcedward
Copy link
Owner

Forget to upload corresponding files. Re-uploaded

@dataframing
Copy link

@makcedward is there any way we/I can help get this issue's resolution (bundled in #104) pushed to PyPI? Please let me know!

@makcedward
Copy link
Owner

@dataframing
Will work on that asap

@makcedward
Copy link
Owner

pushed to PyPI. Please check.

@subercui
Copy link

I think the issue is still not solved and as @ljvmiranda921 stated

paths here ../../../ becomes different when running nlpaug as a package.

@makcedward
Copy link
Owner

Updated to 0.0.13.3 version. It included json file.

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

4 participants