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

punkt doesn't work as of nltk 3.8.2 #216

Open
tomteecezint opened this issue Aug 13, 2024 · 1 comment
Open

punkt doesn't work as of nltk 3.8.2 #216

tomteecezint opened this issue Aug 13, 2024 · 1 comment

Comments

@tomteecezint
Copy link

punkt is loaded in as a pickle file which is not secure CVE-2024-39705 so you have to use punkt_tab now.
This breaks _get_sentence_tokenizer.

In order to use the Tokeniser class I had to override _get_sentence_tokenizer like this:

    def _get_sentence_tokenizer(self, language):
        """ We are overriding this as we need to replace punkt with punkt_tab in sumy"""
        if language in self.SPECIAL_SENTENCE_TOKENIZERS:
            return self.SPECIAL_SENTENCE_TOKENIZERS[language]
        try:
            return PunktTokenizer(language)
        except (LookupError, zipfile.BadZipfile) as e:
            raise LookupError(
                "NLTK tokenizers are missing or the language is not supported.\n"
                """Download them by following command: python -c "import nltk; nltk.download('punkt_tab')"\n"""
                "Original error was:\n" + str(e)
            )

Also change nltk.download('punkt') to nltk.download('punkt_tab')

@tomteecezint
Copy link
Author

See this thread - nltk/nltk#3293

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

1 participant