Don't rename component in intent parser example (resolves #1551)

Otherwise, the default saved model won't know that it's supposed to create spaCy's 'parser'.
This commit is contained in:
ines 2017-11-10 23:35:38 +01:00
parent 35653bef3a
commit f36fab39b0
1 changed files with 4 additions and 5 deletions

View File

@ -72,19 +72,18 @@ def main(model=None, output_dir=None, n_iter=5):
nlp = spacy.blank('en') # create blank Language class
print("Created blank 'en' model")
# We'll use the built-in dependency parser
# class, but we want to create a fresh instance, and give it a different
# name.
# We'll use the built-in dependency parser class, but we want to create a
# fresh instance just in case.
if 'parser' in nlp.pipe_names:
nlp.remove_pipe('parser')
parser = nlp.create_pipe('parser')
nlp.add_pipe(parser, name='intent-parser', first=True)
nlp.add_pipe(parser, first=True)
for text, annotations in TRAIN_DATA:
for dep in annotations.get('deps', []):
parser.add_label(dep)
other_pipes = [pipe for pipe in nlp.pipe_names if pipe != 'intent-parser']
other_pipes = [pipe for pipe in nlp.pipe_names if pipe != 'parser']
with nlp.disable_pipes(*other_pipes): # only train parser
optimizer = nlp.begin_training()
for itn in range(n_iter):