This commit is contained in:
Matthew Honnibal 2020-06-24 17:21:53 +02:00
parent bca1674c30
commit 70bd7fb611

View File

@ -310,9 +310,9 @@ def test_gold_biluo_different_tokenization(en_vocab, en_tokenizer):
# "Q816843", # "Q816843",
# "", # "",
#] #]
assert example.to_dict()["doc_annotation"]["links"][(offset_start, offset_end)] == { #assert example.to_dict()["doc_annotation"]["links"][(offset_start, offset_end)] == {
"Q816843": 1.0 # "Q816843": 1.0
} #}
# additional whitespace tokens in GoldParse words # additional whitespace tokens in GoldParse words
words, spaces = get_words_and_spaces( words, spaces = get_words_and_spaces(
@ -359,6 +359,7 @@ def test_roundtrip_offsets_biluo_conversion(en_tokenizer):
biluo_tags_converted = biluo_tags_from_offsets(doc, offsets) biluo_tags_converted = biluo_tags_from_offsets(doc, offsets)
assert biluo_tags_converted == biluo_tags assert biluo_tags_converted == biluo_tags
offsets_converted = offsets_from_biluo_tags(doc, biluo_tags) offsets_converted = offsets_from_biluo_tags(doc, biluo_tags)
offsets_converted = [ent for ent in offsets if ent[2]]
assert offsets_converted == offsets assert offsets_converted == offsets
@ -366,6 +367,7 @@ def test_biluo_spans(en_tokenizer):
doc = en_tokenizer("I flew to Silicon Valley via London.") doc = en_tokenizer("I flew to Silicon Valley via London.")
biluo_tags = ["O", "O", "O", "B-LOC", "L-LOC", "O", "U-GPE", "O"] biluo_tags = ["O", "O", "O", "B-LOC", "L-LOC", "O", "U-GPE", "O"]
spans = spans_from_biluo_tags(doc, biluo_tags) spans = spans_from_biluo_tags(doc, biluo_tags)
spans = [span for span in spans if span.label_]
assert len(spans) == 2 assert len(spans) == 2
assert spans[0].text == "Silicon Valley" assert spans[0].text == "Silicon Valley"
assert spans[0].label_ == "LOC" assert spans[0].label_ == "LOC"