Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 31 lines (27 sloc) 0.947 kb
532e9be @cathywu adding position tagged data, along with script to generate the data
authored
1 #!/usr/bin/python
2 import os
3
4 def tagfiles(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(" ")
9 w = open("%s/%s" % (newdir,filename), 'w')
10 length = len(f)
11 for i in range(length):
12 if i < length/4:
13 w.write("%s_Q1 " % f[i])
14 elif i < length*3/4:
15 w.write("%s_Q23 " % f[i])
16 else:
17 w.write("%s_Q4 " % f[i])
18 w.close()
19
20 if __name__ == "__main__":
e36917d @cathywu removed yelp data from repo, modified position tagging script and adj…
authored
21 # usage: python position_tagger.py -d neg
22 # usage: python position_tagger.py -d yelp/default/1star
23 from optparse import OptionParser
24 parser = OptionParser()
25 parser.add_option("-d", "--dir", dest="directory")
26 (options, args) = parser.parse_args()
27
28 olddir = options.directory
29 newdir = "%s_position" % olddir
30 tagfiles(olddir, newdir)
Something went wrong with that request. Please try again.