I am using the following code to summarize my text in Python. The code is being run in Jupyter Notebook. I have already install sumy using pip command.
pip install sumy nltk
python -m nltk.downloader punkt
from sumy.parsers.plaintext import PlaintextParser
from sumy.nlp.tokenizers import Tokenizer
from sumy.summarizers.lsa import LsaSummarizer
from io import StringIO
# Define the text to be summarized
text = """
Natural Language Processing (NLP) is a field of artificial intelligence that focuses on the interaction between computers and humans through natural language. The ultimate objective of NLP is to enable computers to understand, interpret, and respond to human language in a way that is both valuable and meaningful.
NLP is used to apply algorithms to identify and extract the natural language rules such that the unstructured language data is converted into a form that computers can understand. When the text has been provided, a computer can take many different approaches to process it. The algorithm can be a rule-based or a machine learning-based approach.
"""
# Use StringIO to simulate a file-like object
text_io = StringIO(text)
# Parse the text
parser = PlaintextParser.from_file(text_io, Tokenizer("english"))
# Initialize the LSA summarizer
summarizer = LsaSummarizer()
# Generate the summary (you can adjust the number of sentences)
summary = summarizer(parser.document, sentences_count=2)
# Print the summary
for sentence in summary:
print(sentence)
When I run the program I get the following error:
ame)
662 def find_class(self, module, name):
663 # Forbid every function
--> 664 raise pickle.UnpicklingError(f"global '{module}.{name}' is forbidden")
UnpicklingError: global 'copy_reg._reconstructor' is forbidden
Any ideas!