CoolFace
Apppublic

shamim237/python-dev-task-skyranko

sourceHugging Faceupdated 4y agoView on Hugging Face
0likes
summary.py25 linesDownload Raw Back to root
1import nltk2import streamlit as st3from sumy.nlp.tokenizers import Tokenizer4from sumy.parsers.plaintext import PlaintextParser5from sumy.summarizers.lex_rank import LexRankSummarizer6 7@st.cache(allow_output_mutation=True, ttl=48*3600)8def dwnld_lib():9    nltk.download('punkt')10    11dwnld_lib()12 13def text_summary(text):14    para = " ".join(text)15    # Create a plaintext parser and tokenizer16    parser = PlaintextParser.from_string(para, Tokenizer("english"))17    # Create a LexRank summarizer18    summarizer = LexRankSummarizer()19    # Summarize the text and print the results20    summ = []21    for sentence in summarizer(parser.document, 4):22        summy =  str(sentence).capitalize()23        summ.append(summy)24    return summ25