mirror of https://github.com/explosion/spaCy.git
Add set_morphology cfg option for Tagger
This commit is contained in:
parent
49cf002ac4
commit
c91577db02
|
@ -357,6 +357,14 @@ class Tagger(Pipe):
|
|||
self.cfg = OrderedDict(sorted(cfg.items()))
|
||||
self.cfg.setdefault("cnn_maxout_pieces", 2)
|
||||
|
||||
@property
|
||||
def set_morphology(self):
|
||||
return self.cfg.get("set_morphology", True)
|
||||
|
||||
@property.setter
|
||||
def set_morphology(self, value):
|
||||
return self.cfg["set_morphology"] = True
|
||||
|
||||
@property
|
||||
def labels(self):
|
||||
return tuple(self.vocab.morphology.tag_names)
|
||||
|
@ -410,12 +418,13 @@ class Tagger(Pipe):
|
|||
doc_tag_ids = doc_tag_ids.get()
|
||||
for j, tag_id in enumerate(doc_tag_ids):
|
||||
# Don't clobber preset POS tags
|
||||
if doc.c[j].tag == 0 and doc.c[j].pos == 0:
|
||||
# Don't clobber preset lemmas
|
||||
lemma = doc.c[j].lemma
|
||||
vocab.morphology.assign_tag_id(&doc.c[j], tag_id)
|
||||
if lemma != 0 and lemma != doc.c[j].lex.orth:
|
||||
doc.c[j].lemma = lemma
|
||||
if doc.c[j].tag == 0:
|
||||
if doc.c[j].pos == 0 and self.set_morphology:
|
||||
# Don't clobber preset lemmas
|
||||
lemma = doc.c[j].lemma
|
||||
vocab.morphology.assign_tag_id(&doc.c[j], tag_id)
|
||||
if lemma != 0 and lemma != doc.c[j].lex.orth:
|
||||
doc.c[j].lemma = lemma
|
||||
idx += 1
|
||||
if tensors is not None and len(tensors):
|
||||
if isinstance(doc.tensor, numpy.ndarray) \
|
||||
|
|
Loading…
Reference in New Issue