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

try to load nlp on importing package #88

Open
flashpixx opened this issue Jan 12, 2021 · 1 comment
Open

try to load nlp on importing package #88

flashpixx opened this issue Jan 12, 2021 · 1 comment
Labels

Comments

@flashpixx
Copy link

flashpixx commented Jan 12, 2021

I have got a problem, because this code in the utilities.py is executed everytime if utilities packages is imported:

try:
    nlp
except NameError:
    nlp = spacy.load('en_core_web_lg')

In my case I don't have installed the en_core_web_lg because I would like to use my own NLP. In the geiparse.py the class uses the utilities (on import) and it breaks. I will set the nlp argument:

class Geoparser:
    def __init__(self, nlp=None, es_hosts=None, es_port=None, es_ssl=False, es_auth=None,
                 verbose=False, country_threshold=0.6, threads=True,
                 progress=True, training=None, models_path=None, **kwargs):
        DATA_PATH = pkg_resources.resource_filename('mordecai', 'data/')
        if not models_path:
            models_path = pkg_resources.resource_filename('mordecai', 'models/')
            print("Models path:", models_path)
        if nlp:
            self.nlp = nlp
        else:
            try:
                self.nlp = spacy.load('en_core_web_lg', disable=['parser', 'tagger']) 
            except OSError:
                print("""ERROR: No spaCy NLP model installed. Install with this command: 
                `python -m spacy download en_core_web_lg`.""") 

IMHO the import of the en_core_web_lg in the utilities.py should be removed because it is redundant.

Thanks

@ahalterman
Copy link
Member

Thanks for that catch! I'm hoping to do a refresh of the whole codebase in February and I'll definitely remove that redundant import when I do.

@ahalterman ahalterman added the v3 label Jan 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants