mirror of
https://github.com/explosion/spaCy.git
synced 2024-11-11 04:08:09 +03:00
fixed bug in training ner documentation and example
This commit is contained in:
parent
f69ff15089
commit
dfaeee1f37
|
@ -52,6 +52,7 @@ def train_ner(nlp, train_data, output_dir):
|
|||
random.shuffle(train_data)
|
||||
loss = 0.
|
||||
for raw_text, entity_offsets in train_data:
|
||||
doc = nlp.make_doc(raw_text)
|
||||
gold = GoldParse(doc, entities=entity_offsets)
|
||||
# By default, the GoldParse class assumes that the entities
|
||||
# described by offset are complete, and all other words should
|
||||
|
@ -63,7 +64,6 @@ def train_ner(nlp, train_data, output_dir):
|
|||
#for i in range(len(gold.ner)):
|
||||
#if not gold.ner[i].endswith('ANIMAL'):
|
||||
# gold.ner[i] = '-'
|
||||
doc = nlp.make_doc(raw_text)
|
||||
nlp.tagger(doc)
|
||||
# As of 1.9, spaCy's parser now lets you supply a dropout probability
|
||||
# This might help the model generalize better from only a few
|
||||
|
|
|
@ -150,8 +150,8 @@ p
|
|||
for itn in range(20):
|
||||
random.shuffle(train_data)
|
||||
for raw_text, entity_offsets in train_data:
|
||||
gold = GoldParse(doc, entities=entity_offsets)
|
||||
doc = nlp.make_doc(raw_text)
|
||||
gold = GoldParse(doc, entities=entity_offsets)
|
||||
nlp.tagger(doc)
|
||||
loss = nlp.entity.update(doc, gold)
|
||||
nlp.end_training()
|
||||
|
|
Loading…
Reference in New Issue
Block a user