-
Notifications
You must be signed in to change notification settings - Fork 0
/
sum.py
51 lines (40 loc) · 1.84 KB
/
sum.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
50
51
import argparse
import logging
from clstk.utils import colors
from clstk import linBilmes
from clstk import coRank
from clstk import simFusion
if __name__ == '__main__':
common_parser = argparse.ArgumentParser(add_help=False)
common_parser.add_argument('source_directory',
help='Directory containing a set of files to '
'be summarized.')
common_parser.add_argument('-v', '--verbose', action='store_true',
help='Show verbose information messages')
common_parser.add_argument('--no-colors', action='store_true',
help='Don\'t show colors in verbose log')
parser = argparse.ArgumentParser(
description='Automatically summarize a set of documents'
)
subparsers = parser.add_subparsers(title='methods',
description='Summarization method')
linBilmes.setupArgparse(subparsers.add_parser('linBilmes',
parents=[common_parser]))
coRank.setupArgparse(subparsers.add_parser('coRank',
parents=[common_parser]))
simFusion.setupArgparse(subparsers.add_parser('simFusion',
parents=[common_parser]))
args = parser.parse_args()
if args.no_colors:
colors.disable()
logLevel = logging.NOTSET if args.verbose else logging.WARNING
logging.basicConfig(
level=logLevel,
format=(colors.enclose('%(asctime)s', colors.CYAN) +
colors.enclose('.%(msecs)03d ', colors.BLUE) +
colors.enclose('%(name)s', colors.YELLOW) + ': ' +
'%(message)s'),
datefmt='%Y-%m-%d %H:%M:%S'
)
logging.info("Initializing summarizer")
args.func(args)