-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathverb_filter.py
More file actions
executable file
·25 lines (22 loc) · 852 Bytes
/
verb_filter.py
File metadata and controls
executable file
·25 lines (22 loc) · 852 Bytes
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
#!/usr/bin/python
import os
def filter_adj(olddir, newdir):
if not os.path.isdir(newdir):
os.mkdir(newdir)
for filename in os.listdir(olddir):
f = open("%s/%s" % (olddir,filename)).read().split("\n")
w = open("%s/%s" % (newdir,filename), 'w')
for word in f:
if word[-4:]=='_VBZ' or word[-4:]=="_VBD" or word[-3:]=="_VB":
w.write("%s\n" % word)
w.close()
if __name__ == "__main__":
# usage: python adjectives_filter.py -d neg
# usage: python adjectives_filter.py -d yelp/default/1star
from optparse import OptionParser
parser = OptionParser()
parser.add_option("-d", "--dir", dest="directory")
(options, args) = parser.parse_args()
olddir = "%s_tagged" % options.directory
newdir = "%s_verb" % options.directory
filter_adj(olddir,newdir)