-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathall.py
94 lines (74 loc) · 2.08 KB
/
all.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import sys
import getopt
from os import path
from parse import createTokenizedFile
from count import wordCount
from summary import textSummarization
from cloud import makeWordCloud
from sentiment import analyzeSentiment
def printCmd():
print("all.py -i <inputfile> -m <maskfile> -r|--root")
def main(argv):
input = None
mask = None
root = False
try:
opts, args = getopt.getopt(argv, "hi:m:r", [
"input=",
"mask=",
"root",
])
except getopt.GetoptError:
printCmd()
sys.exit(2)
if len(opts) < 1:
printCmd()
sys.exit()
else:
for opt, arg in opts:
if opt == '-h':
printCmd()
sys.exit()
elif opt in ("-i", "--input"):
input = arg.strip()
elif opt in ("-m", "--mask"):
mask = arg.strip()
elif opt in ('-r', '--root'):
root = True
basename = path.basename(path.splitext(input)[0])
if(mask is None):
maskCloud = path.join(path.dirname(input), basename + ".png")
else:
maskCloud = mask
files = []
# Sentiment
analyzeSentiment(
input,
)
# Tokenization para generacion de conteos y nubes
tokenizedFile = createTokenizedFile(
input,
False
)
files.append(tokenizedFile)
if(root == True):
# Root
tokenizedRootFile = createTokenizedFile(
input,
True
)
files.append(tokenizedRootFile)
for file in files:
# Conteo
wordCount(file, False)
# Conteo ordenado de mayor a menor
wordCount(file, True)
# Nube
makeWordCloud(file)
if path.exists(maskCloud):
# Nube con mascara
makeWordCloud(file, maskCloud)
# Sumarizacion
textSummarization(input)
if __name__ == "__main__":
main(sys.argv[1:])