Skip to content

Commit

Permalink
ENH Added script to create a single gazetteer file.
Browse files Browse the repository at this point in the history
  • Loading branch information
andre-martins committed Oct 13, 2014
1 parent 4f77016 commit 3b2f8d6
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions scripts_ner/create_gazetteer_file.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import os
import sys

if __name__ == "__main__":
path = sys.argv[1] # Path to the folder where the gazetteers are.
destination_filepath = sys.argv[2] # Path to the destination file.
f_out = open(destination_filepath, 'w')
gazetteers_list = [name for name in os.listdir(path) if
not os.path.isdir(path + os.sep + name)]
gazetteers_list.sort()
for name in gazetteers_list:
print 'Adding ', name, '...'
filepath = path + os.sep + name
f = open(filepath)
for line in f:
line = line.rstrip('\r\n')
f_out.write('%s\t%s\n' % (name, line))
f_out.close()

0 comments on commit 3b2f8d6

Please sign in to comment.