mirror of
https://github.com/explosion/spaCy.git
synced 2025-02-06 14:40:34 +03:00
fix MORPH conversion + enable unit test
This commit is contained in:
parent
a5ee082da1
commit
face0de74f
|
@ -13,7 +13,7 @@ from ..errors import Errors, AlignmentError
|
||||||
cpdef Doc annotations2doc(Doc predicted, tok_annot, doc_annot):
|
cpdef Doc annotations2doc(Doc predicted, tok_annot, doc_annot):
|
||||||
# TODO: Improve and test this
|
# TODO: Improve and test this
|
||||||
words = tok_annot.get("ORTH", [tok.text for tok in predicted])
|
words = tok_annot.get("ORTH", [tok.text for tok in predicted])
|
||||||
attrs, array = _annot2array(predicted.vocab.strings, tok_annot, doc_annot)
|
attrs, array = _annot2array(predicted.vocab, tok_annot, doc_annot)
|
||||||
output = Doc(predicted.vocab, words=words)
|
output = Doc(predicted.vocab, words=words)
|
||||||
if array.size:
|
if array.size:
|
||||||
output = output.from_array(attrs, array)
|
output = output.from_array(attrs, array)
|
||||||
|
@ -117,6 +117,9 @@ def _annot2array(vocab, tok_annot, doc_annot):
|
||||||
elif key == "SENT_START":
|
elif key == "SENT_START":
|
||||||
attrs.append(key)
|
attrs.append(key)
|
||||||
values.append(value)
|
values.append(value)
|
||||||
|
elif key == "MORPH":
|
||||||
|
attrs.append(key)
|
||||||
|
values.append([vocab.morphology.add(v) for v in value])
|
||||||
elif key == "ENT_IOB":
|
elif key == "ENT_IOB":
|
||||||
iob_strings = Token.iob_strings()
|
iob_strings = Token.iob_strings()
|
||||||
attrs.append(key)
|
attrs.append(key)
|
||||||
|
|
|
@ -60,7 +60,6 @@ def test_Example_from_dict_with_parse(annots):
|
||||||
assert token.head.i == annots["heads"][i]
|
assert token.head.i == annots["heads"][i]
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.xfail(reason="TODO - fix")
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"annots",
|
"annots",
|
||||||
[
|
[
|
||||||
|
|
Loading…
Reference in New Issue
Block a user