Spaces:
Runtime error
Runtime error
Download summary.py from shamim237/python-dev-task-skyranko: direct link, hf CLI and curl.
- Browser
- Download file 734 Bytes
-
https://huggingface.co/spaces/shamim237/python-dev-task-skyranko/resolve/main/summary.py
- Command line
-
hf download hf://spaces/shamim237/python-dev-task-skyranko/summary.py
-
curl -L -o summary.py https://huggingface.co/spaces/shamim237/python-dev-task-skyranko/resolve/main/summary.py
734 Bytes
| import nltk | |
| import streamlit as st | |
| from sumy.nlp.tokenizers import Tokenizer | |
| from sumy.parsers.plaintext import PlaintextParser | |
| from sumy.summarizers.lex_rank import LexRankSummarizer | |
| def dwnld_lib(): | |
| nltk.download('punkt') | |
| dwnld_lib() | |
| def text_summary(text): | |
| para = " ".join(text) | |
| # Create a plaintext parser and tokenizer | |
| parser = PlaintextParser.from_string(para, Tokenizer("english")) | |
| # Create a LexRank summarizer | |
| summarizer = LexRankSummarizer() | |
| # Summarize the text and print the results | |
| summ = [] | |
| for sentence in summarizer(parser.document, 4): | |
| summy = str(sentence).capitalize() | |
| summ.append(summy) | |
| return summ | |