-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathml-analyze.py
executable file
·62 lines (42 loc) · 1.78 KB
/
ml-analyze.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
#!/usr/bin/python
import glob
import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from core.ui import MainWindow, AnalysisData
from core.engine import TextAnalyser, DirAnalyser
from optparse import OptionParser
def main():
parser = OptionParser();
parser.add_option("-d","--text-dir", action="store", type="string",
dest="textDir", default="text-dir")
parser.add_option("-l","--lang", action="store", type="string",
dest="lang", default="en")
parser.add_option("-f","--format", action="store", type="string",
dest="format", default="txt")
parser.add_option("-m","--module", action="store", type="string",
dest="module", default="lexical_density",
help="Lexical feature to compute; default: lexical_density")
parser.add_option("--nw","--no-window", action="store_true",
dest="nw", default=False, help="Don't use the GUI")
(options, args) = parser.parse_args()
attributes = []
attributes.append(options.module)
analyserList = []
dirAnalyser = DirAnalyser(options.textDir, options.lang, options.format)
analyserList = dirAnalyser.analyse(attributes)
if options.nw:
print repr("File Name"), repr(attributes[0])
for a in analyserList:
print repr(a.fileName), \
repr("{0:.3f}".format(a.getResult(attributes[0])))
else:
app = QApplication(sys.argv)
app.setApplicationName('multiple language translationese')
dataModel = AnalysisData(analyserList, attributes)
mainWindow = MainWindow(dataModel)
mainWindow.update()
mainWindow.show()
sys.exit(app.exec_())
if __name__=='__main__':
main()