forked from andre-martins/TurboParser
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ENH Added script to create a single gazetteer file.
- Loading branch information
1 parent
4f77016
commit 3b2f8d6
Showing
1 changed file
with
18 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |