Save vectors init

This commit is contained in:
Matthew Honnibal 2018-07-03 23:55:04 +02:00
parent 6692833887
commit 1e38bea6e9

View File

@ -69,7 +69,8 @@ def init_model(lang, output_dir, freqs_loc=None, clusters_loc=None, jsonl_loc=No
vectors_loc = ensure_path(vectors_loc)
if vectors_loc and vectors_loc.parts[-1].endswith('.npz'):
vectors_data = numpy.load(vectors_loc.open('rb'))
vector_keys = [lex['orth'] for lex in lex_attrs if 'id' in lex]
vector_keys = [lex['orth'] for lex in lex_attrs
if 'rank' in lex and lex['rank'] < vectors_data.shape[0]]
else:
vectors_data, vector_keys = read_vectors(vectors_loc) if vectors_loc else (None, None)
nlp = create_model(lang, lex_attrs, vectors_data, vector_keys, prune_vectors)