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

Stopwords do not load properly #382

Closed
jenniferjiangkells opened this issue Dec 18, 2023 · 4 comments
Closed

Stopwords do not load properly #382

jenniferjiangkells opened this issue Dec 18, 2023 · 4 comments

Comments

@jenniferjiangkells
Copy link
Contributor

The stopwords do not load in MedCAT - we've been passing in a set of stopwords from the MedCAT config and this set of stopwords is entirely ignored as MedCAT still uses the spacy defaults. This is because to load a set of stopwords in spacy, you need to initialise this in the Language.Defaults class BEFORE the spacy model is loaded (see explosion/spaCy#10942)

I believe all you need to do is change the order of initialisation in medcat/pipe.py to:

from spacy.language import Language

if config.preprocessing.stopwords is not None:
   Language.Defaults.stop_words = set(config.preprocessing.stopwords)
self._nlp = spacy.load(config.general.spacy_model, disable=config.general.spacy_disabled_components)

@mart-r
Copy link
Collaborator

mart-r commented Dec 18, 2023

Thank you for the report along with a proposed solution.

Would you mind submitting the proposed change along with some automated tests as a pull request?

@jenniferjiangkells
Copy link
Contributor Author

jenniferjiangkells commented Dec 18, 2023

@mart-r Done - I've referenced this issue in the PR

@mart-r
Copy link
Collaborator

mart-r commented Dec 19, 2023

Thanks for the PR. It's much appreciated!

@mart-r
Copy link
Collaborator

mart-r commented Jan 8, 2024

Addressed and merged in PR #383

@mart-r mart-r closed this as completed Jan 8, 2024
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