def create_set(categories, outfile):
"""
Creates a test-set .txt file for use in word2vec.
Conforms to word2vec specs, from the google code repository: https://code.google.com/archive/p/word2vec/
:param categories: The categories and words in the categories: {NAME: [[tuple_1],[tuple_2],...,[tuple_n]]}
:param outfile: The file to which to write the text.
:return: None
"""
with open(outfile, 'w', encoding='utf8') as f:
for k, v in categories.items():
f.write(u": {0}\n".format(k))
for x in permutations([" ".join(x).lower() for x in v], 2):
f.write(u"{0}\n".format(" ".join(x)))
评论列表
文章目录