d0r1h commited on
Commit
d3c86fd
1 Parent(s): 38d3497

Create Extractive.py

Browse files
Files changed (1) hide show
  1. Summarizer/Extractive.py +21 -0
Summarizer/Extractive.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import nltk
2
+ from sumy.parsers.plaintext import PlaintextParser
3
+ from sumy.summarizers.luhn import LuhnSummarizer
4
+ from sumy.nlp.tokenizers import Tokenizer
5
+
6
+ nltk.download('punkt')
7
+
8
+ def summarize(file, SENTENCES_COUNT):
9
+
10
+ sumarizer = LuhnSummarizer()
11
+ with open(file.name) as f:
12
+ doc = f.read()
13
+
14
+ sentences_ = []
15
+ doc_ = PlaintextParser(doc, Tokenizer("en")).document
16
+ for sentence in sumarizer(doc_, SENTENCES_COUNT):
17
+ sentences_.append(str(sentence))
18
+
19
+ summm_ = " ".join(sentences_)
20
+
21
+ return summm_