mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-27 02:16:32 +03:00
Merge pull request #1789 from sorenlind/init_model_args
Fix CLI arguments for init-model
This commit is contained in:
commit
03a2f540ca
|
@ -25,7 +25,7 @@ from ..util import prints, ensure_path, get_lang_class
|
||||||
prune_vectors=("optional: number of vectors to prune to",
|
prune_vectors=("optional: number of vectors to prune to",
|
||||||
"option", "V", int)
|
"option", "V", int)
|
||||||
)
|
)
|
||||||
def init_model(lang, output_dir, freqs_loc, clusters_loc=None, vectors_loc=None, prune_vectors=-1):
|
def init_model(_cmd, lang, output_dir, freqs_loc, clusters_loc=None, vectors_loc=None, prune_vectors=-1):
|
||||||
"""
|
"""
|
||||||
Create a new model from raw data, like word frequencies, Brown clusters
|
Create a new model from raw data, like word frequencies, Brown clusters
|
||||||
and word vectors.
|
and word vectors.
|
||||||
|
@ -36,7 +36,7 @@ def init_model(lang, output_dir, freqs_loc, clusters_loc=None, vectors_loc=None,
|
||||||
vectors_loc = ensure_path(vectors_loc)
|
vectors_loc = ensure_path(vectors_loc)
|
||||||
|
|
||||||
probs, oov_prob = read_freqs(freqs_loc)
|
probs, oov_prob = read_freqs(freqs_loc)
|
||||||
vectors_data, vector_keys = read_vectors(vectors_loc) if vectors_loc else None
|
vectors_data, vector_keys = read_vectors(vectors_loc) if vectors_loc else None, None
|
||||||
clusters = read_clusters(clusters_loc) if clusters_loc else {}
|
clusters = read_clusters(clusters_loc) if clusters_loc else {}
|
||||||
|
|
||||||
nlp = create_model(lang, probs, oov_prob, clusters, vectors_data, vector_keys, prune_vectors)
|
nlp = create_model(lang, probs, oov_prob, clusters, vectors_data, vector_keys, prune_vectors)
|
||||||
|
@ -69,7 +69,7 @@ def create_model(lang, probs, oov_prob, clusters, vectors_data, vector_keys, pru
|
||||||
lex_added += 1
|
lex_added += 1
|
||||||
nlp.vocab.cfg.update({'oov_prob': oov_prob})
|
nlp.vocab.cfg.update({'oov_prob': oov_prob})
|
||||||
|
|
||||||
if len(vectors_data):
|
if vectors_data:
|
||||||
nlp.vocab.vectors = Vectors(data=vectors_data, keys=vector_keys)
|
nlp.vocab.vectors = Vectors(data=vectors_data, keys=vector_keys)
|
||||||
if prune_vectors >= 1:
|
if prune_vectors >= 1:
|
||||||
nlp.vocab.prune_vectors(prune_vectors)
|
nlp.vocab.prune_vectors(prune_vectors)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user