mirror of https://github.com/explosion/spaCy.git
Support loading labels in morphologizer
This commit is contained in:
parent
d6c967401f
commit
8ea8b7d940
|
@ -134,7 +134,7 @@ class Morphologizer(Tagger):
|
||||||
self.cfg["labels_pos"][norm_label] = POS_IDS[pos]
|
self.cfg["labels_pos"][norm_label] = POS_IDS[pos]
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
def initialize(self, get_examples, *, nlp=None):
|
def initialize(self, get_examples, *, nlp=None, labels=None):
|
||||||
"""Initialize the pipe for training, using a representative set
|
"""Initialize the pipe for training, using a representative set
|
||||||
of data examples.
|
of data examples.
|
||||||
|
|
||||||
|
@ -145,6 +145,10 @@ class Morphologizer(Tagger):
|
||||||
DOCS: https://nightly.spacy.io/api/morphologizer#initialize
|
DOCS: https://nightly.spacy.io/api/morphologizer#initialize
|
||||||
"""
|
"""
|
||||||
self._ensure_examples(get_examples)
|
self._ensure_examples(get_examples)
|
||||||
|
if labels is not None:
|
||||||
|
self.cfg["labels_morph"] = labels["labels_morph"]
|
||||||
|
self.cfg["labels_pos"] = labels["labels_pos"]
|
||||||
|
else:
|
||||||
# First, fetch all labels from the data
|
# First, fetch all labels from the data
|
||||||
for example in get_examples():
|
for example in get_examples():
|
||||||
for i, token in enumerate(example.reference):
|
for i, token in enumerate(example.reference):
|
||||||
|
|
Loading…
Reference in New Issue