mirror of https://github.com/explosion/spaCy.git
Do pseudo-projective pre-processing for parser
This commit is contained in:
parent
1d5d9838a2
commit
1b5fa68996
|
@ -435,6 +435,7 @@ cdef class Parser:
|
|||
def begin_training(self, gold_tuples, **cfg):
|
||||
if 'model' in cfg:
|
||||
self.model = cfg['model']
|
||||
gold_tuples = PseudoProjectivity.preprocess_training_data(gold_tuples)
|
||||
actions = self.moves.get_actions(gold_parses=gold_tuples)
|
||||
for action, labels in actions.items():
|
||||
for label in labels:
|
||||
|
@ -442,6 +443,12 @@ cdef class Parser:
|
|||
if self.model is True:
|
||||
self.model = self.Model(self.moves.n_moves, **cfg)
|
||||
|
||||
def preprocess_gold(self, docs_golds):
|
||||
for doc, gold in docs_golds:
|
||||
gold.heads, gold.labels = PseudoProjectivity.projectivize(
|
||||
gold.heads, gold.labels)
|
||||
yield doc, gold
|
||||
|
||||
def use_params(self, params):
|
||||
# Can't decorate cdef class :(. Workaround.
|
||||
with self.model[0].use_params(params):
|
||||
|
|
Loading…
Reference in New Issue