mirror of
https://github.com/explosion/spaCy.git
synced 2025-07-13 01:32:32 +03:00
Fix example
This commit is contained in:
parent
281f88a59c
commit
d425ede7e9
|
@ -44,7 +44,7 @@ def main(model=None, output_dir=None, n_iter=100):
|
||||||
print("Created blank 'en' model")
|
print("Created blank 'en' model")
|
||||||
|
|
||||||
# create the built-in pipeline components and add them to the pipeline
|
# create the built-in pipeline components and add them to the pipeline
|
||||||
# ner.create_pipe works for built-ins that are registered with spaCy!
|
# nlp.create_pipe works for built-ins that are registered with spaCy
|
||||||
if 'ner' not in nlp.pipe_names:
|
if 'ner' not in nlp.pipe_names:
|
||||||
ner = nlp.create_pipe('ner')
|
ner = nlp.create_pipe('ner')
|
||||||
nlp.add_pipe(ner, last=True)
|
nlp.add_pipe(ner, last=True)
|
||||||
|
@ -86,8 +86,9 @@ def main(model=None, output_dir=None, n_iter=100):
|
||||||
|
|
||||||
# test the saved model
|
# test the saved model
|
||||||
print("Loading from", output_dir)
|
print("Loading from", output_dir)
|
||||||
|
nlp2 = spacy.load(output_dir)
|
||||||
for text, _ in TRAIN_DATA:
|
for text, _ in TRAIN_DATA:
|
||||||
doc = nlp(text)
|
doc = nlp2(text)
|
||||||
print('Entities', [(ent.text, ent.label_) for ent in doc.ents])
|
print('Entities', [(ent.text, ent.label_) for ent in doc.ents])
|
||||||
print('Tokens', [(t.text, t.ent_type_, t.ent_iob) for t in doc])
|
print('Tokens', [(t.text, t.ent_type_, t.ent_iob) for t in doc])
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user