Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 26 lines (22 sloc) 0.852 kb
88c0b96 @cathywu added preprocessing for yelp data, filtering for verbs,docs for data …
authored
1 #!/usr/bin/python
2 import os
3
4 def filter_adj(olddir, newdir):
5 if not os.path.isdir(newdir):
6 os.mkdir(newdir)
7 for filename in os.listdir(olddir):
8 f = open("%s/%s" % (olddir,filename)).read().split("\n")
9 w = open("%s/%s" % (newdir,filename), 'w')
10 for word in f:
11 if word[-4:]=='_VBZ' or word[-4:]=="_VBD" or word[-3:]=="_VB":
12 w.write("%s\n" % word)
13 w.close()
14
15 if __name__ == "__main__":
16 # usage: python adjectives_filter.py -d neg
17 # usage: python adjectives_filter.py -d yelp/default/1star
18 from optparse import OptionParser
19 parser = OptionParser()
20 parser.add_option("-d", "--dir", dest="directory")
21 (options, args) = parser.parse_args()
22
23 olddir = "%s_tagged" % options.directory
24 newdir = "%s_verb" % options.directory
25 filter_adj(olddir,newdir)
Something went wrong with that request. Please try again.