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 = OrderedDict(sorted(cfg.items()))
|
||||||
self.cfg.setdefault("cnn_maxout_pieces", 2)
|
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
|
@property
|
||||||
def labels(self):
|
def labels(self):
|
||||||
return tuple(self.vocab.morphology.tag_names)
|
return tuple(self.vocab.morphology.tag_names)
|
||||||
|
@ -410,12 +418,13 @@ class Tagger(Pipe):
|
||||||
doc_tag_ids = doc_tag_ids.get()
|
doc_tag_ids = doc_tag_ids.get()
|
||||||
for j, tag_id in enumerate(doc_tag_ids):
|
for j, tag_id in enumerate(doc_tag_ids):
|
||||||
# Don't clobber preset POS tags
|
# Don't clobber preset POS tags
|
||||||
if doc.c[j].tag == 0 and doc.c[j].pos == 0:
|
if doc.c[j].tag == 0:
|
||||||
# Don't clobber preset lemmas
|
if doc.c[j].pos == 0 and self.set_morphology:
|
||||||
lemma = doc.c[j].lemma
|
# Don't clobber preset lemmas
|
||||||
vocab.morphology.assign_tag_id(&doc.c[j], tag_id)
|
lemma = doc.c[j].lemma
|
||||||
if lemma != 0 and lemma != doc.c[j].lex.orth:
|
vocab.morphology.assign_tag_id(&doc.c[j], tag_id)
|
||||||
doc.c[j].lemma = lemma
|
if lemma != 0 and lemma != doc.c[j].lex.orth:
|
||||||
|
doc.c[j].lemma = lemma
|
||||||
idx += 1
|
idx += 1
|
||||||
if tensors is not None and len(tensors):
|
if tensors is not None and len(tensors):
|
||||||
if isinstance(doc.tensor, numpy.ndarray) \
|
if isinstance(doc.tensor, numpy.ndarray) \
|
||||||
|
|
Loading…
Reference in New Issue