mirror of
https://github.com/explosion/spaCy.git
synced 2024-11-14 05:37:03 +03:00
Set extensions when write_conllu() is called in UD train script (#4618)
* Set extensions when write_conllu() is called `run_eval.py` uses the `write_conllu()` function from `ud_train.py` by itself, so it needs to set the token extensions if necessary. * Switch from try to if
This commit is contained in:
parent
0b9a5f4074
commit
f415e9b7d1
|
@ -221,6 +221,13 @@ def evaluate(nlp, text_loc, gold_loc, sys_loc, limit=None):
|
||||||
|
|
||||||
|
|
||||||
def write_conllu(docs, file_):
|
def write_conllu(docs, file_):
|
||||||
|
if not Token.has_extension("get_conllu_lines"):
|
||||||
|
Token.set_extension("get_conllu_lines", method=get_token_conllu)
|
||||||
|
if not Token.has_extension("begins_fused"):
|
||||||
|
Token.set_extension("begins_fused", default=False)
|
||||||
|
if not Token.has_extension("inside_fused"):
|
||||||
|
Token.set_extension("inside_fused", default=False)
|
||||||
|
|
||||||
merger = Matcher(docs[0].vocab)
|
merger = Matcher(docs[0].vocab)
|
||||||
merger.add("SUBTOK", None, [{"DEP": "subtok", "op": "+"}])
|
merger.add("SUBTOK", None, [{"DEP": "subtok", "op": "+"}])
|
||||||
for i, doc in enumerate(docs):
|
for i, doc in enumerate(docs):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user