Created
June 26, 2024 14:49
-
-
Save aaditkamat/86132a11b06cfe5497fe793474d9f221 to your computer and use it in GitHub Desktop.
Summarize any text in 13 sentences using Sumy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sumy.parsers.plaintext import PlaintextParser | |
from sumy.nlp.tokenizers import Tokenizer | |
from sumy.summarizers.lsa import LsaSummarizer | |
with open('transcript.txt') as in_file: | |
text = in_file.read() | |
parser = PlaintextParser.from_string(text, Tokenizer("english")) | |
summarizer = LsaSummarizer() | |
num_sentences = 13 | |
summary = summarizer(parser.document, num_sentences) # The number '3' indicates the number of sentences in the summary | |
with open('summarized_transcript.txt', mode='w') as out_file: | |
for sentence in summary: | |
out_file.write(str(sentence) + '\n') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment