Python package sums throwing errors in Jupyter notebook

  Kiến thức lập trình

I am trying to use sumy to summarize text but keep getting weird issues. I am using the following code.

import nltk
nltk.download('punkt')

import sumy 

from sumy.parsers.plaintext import PlaintextParser
from sumy.nlp.tokenizers import Tokenizer
from sumy.summarizers.lsa import LsaSummarizer

# Your text to summarize
text = """
Your long text here...
"""

# Create a PlaintextParser object
parser = PlaintextParser.from_string(text, Tokenizer("english"))

# Create an LsaSummarizer object
summarizer = LsaSummarizer()

# Summarize the text
summary = summarizer(parser.document, 3)  # Summarize to 3 sentences

# Print the summary
for sentence in summary:
    print(sentence)

But I get the error:

170 try:
    171     path = to_string("tokenizers/punkt/%s.pickle") % to_string(language)
--> 172     return nltk.data.load(path)
    173 except (LookupError, zipfile.BadZipfile) as e:
    174     raise LookupError(
    175         "NLTK tokenizers are missing or the language is not supported.n"
    176         """Download them by following command: python -c "import nltk; nltk.download('punkt')"n"""
    177         "Original error was:n" + str(e)
    178     )

1

Did you try to install theses specficis Tokens by using

python -c "import nltk; nltk.download('english')"

1

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT