mirror of
https://github.com/explosion/spaCy.git
synced 2025-02-04 21:50:35 +03:00
Make it easier to pass explicit no-pruning to vocab
This commit is contained in:
parent
d90a22afe6
commit
c390f2d745
|
@ -22,7 +22,7 @@ from ..util import prints, ensure_path
|
||||||
"option", "V", int)
|
"option", "V", int)
|
||||||
)
|
)
|
||||||
def make_vocab(cmd, lang, output_dir, lexemes_loc,
|
def make_vocab(cmd, lang, output_dir, lexemes_loc,
|
||||||
vectors_loc=None, prune_vectors=0):
|
vectors_loc=None, prune_vectors=-1):
|
||||||
"""Compile a vocabulary from a lexicon jsonl file and word vectors."""
|
"""Compile a vocabulary from a lexicon jsonl file and word vectors."""
|
||||||
if not lexemes_loc.exists():
|
if not lexemes_loc.exists():
|
||||||
prints(lexemes_loc, title="Can't find lexical data", exits=1)
|
prints(lexemes_loc, title="Can't find lexical data", exits=1)
|
||||||
|
@ -49,7 +49,7 @@ def make_vocab(cmd, lang, output_dir, lexemes_loc,
|
||||||
if word.rank:
|
if word.rank:
|
||||||
nlp.vocab.vectors.add(word.orth, row=word.rank)
|
nlp.vocab.vectors.add(word.orth, row=word.rank)
|
||||||
|
|
||||||
if prune_vectors is not None:
|
if prune_vectors >= 1:
|
||||||
remap = nlp.vocab.prune_vectors(prune_vectors)
|
remap = nlp.vocab.prune_vectors(prune_vectors)
|
||||||
if not output_dir.exists():
|
if not output_dir.exists():
|
||||||
output_dir.mkdir()
|
output_dir.mkdir()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user