-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexecute.py
40 lines (33 loc) · 946 Bytes
/
execute.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
#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-
import xml.etree.ElementTree as ET
from features import getfeatures
from count import getopn
import os
RAW_FILES = os.listdir('newtestdata/')
cc = 0
aa = 0
for filename in RAW_FILES:
print 'in execute.py ' + filename
tree = ET.parse('newtestdata/' + filename)
root = tree.getroot()
for child in root:
for childd in child:
if childd.tag != 'sentence':
continue
if childd.text is None:
continue
# print childd.text
wlist = getfeatures(childd.text)
# print wlist[0]
if wlist[0] == 0:
aa += 1
if getopn(wlist):
childd.attrib['polarity'] = 'POS'
else:
childd.attrib['polarity'] = 'NEG'
cc += 1
tree.write('count1ans/' + filename)
print cc
print aa
# vim: sw=4 ts=4 sts=4 expandtab