forked from OpenNMT/OpenNMT-py
-
Notifications
You must be signed in to change notification settings - Fork 5
/
test_summarize.py
executable file
·49 lines (38 loc) · 1.39 KB
/
test_summarize.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from summarizer import AbstractiveSummarizer
if __name__ == "__main__":
FILE_NAME = "sample_de.txt"
texts = []
with open("data/"+FILE_NAME) as f:
for text in f:
texts.append(text)
model = AbstractiveSummarizer(language = 'de', method = 'bert', extract = True)
for summ in model.summarize(texts):
print(summ)
model = AbstractiveSummarizer(language = 'de', method = 'conv', extract = True)
for summ in model.summarize(texts):
print(summ)
model = AbstractiveSummarizer(language = 'de', method = 'bert', extract = False)
for summ in model.summarize(texts):
print(summ)
model = AbstractiveSummarizer(language = 'de', method = 'conv', extract = False)
for summ in model.summarize(texts):
print(summ)
FILE_NAME = "sample_en.txt"
texts = []
with open("data/"+FILE_NAME) as f:
for text in f:
texts.append(text)
model = AbstractiveSummarizer(language = 'en', method = 'bert', extract = True)
for summ in model.summarize(texts):
print(summ)
model = AbstractiveSummarizer(language = 'en', method = 'conv', extract = True)
for summ in model.summarize(texts):
print(summ)
model = AbstractiveSummarizer(language = 'en', method = 'bert', extract = False)
for summ in model.summarize(texts):
print(summ)
model = AbstractiveSummarizer(language = 'en', method = 'conv', extract = False)
for summ in model.summarize(texts):
print(summ)