-
Notifications
You must be signed in to change notification settings - Fork 0
/
vec_to_tsv.py
33 lines (23 loc) · 1.07 KB
/
vec_to_tsv.py
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
26
27
28
29
30
31
32
33
import argparse
from accessible_text_file import AccessibleTextFile
def main():
parser = _initialize_parser()
args = parser.parse_args()
with open(args.output_vec, "w") as modelOut, open(args.output_meta, "w") as metaOut, open(
args.input, "r") as inputFile:
# skip header row
next(inputFile)
for line in inputFile:
tokens = line.split(" ")
without_word = "\t".join(tokens[1:])
print(without_word, file=modelOut, end="")
print(tokens[0], file=metaOut)
def _initialize_parser():
general_parser = argparse.ArgumentParser(description='Named entity recognition')
general_parser.add_argument("--input", help='.vec File containing trained word embeddings',
action=AccessibleTextFile)
general_parser.add_argument("--output-vec", help='Filename for tsv containing vector information')
general_parser.add_argument("--output-meta", help='Filename for tsv containing meta information')
return general_parser
if __name__ == "__main__":
main()