spaCy/spacy/tests/regression/test_issue2385.py
Maciej c7d53348d7 Fix bug in CLI iob and ner converter (#2392) (fixes #2385)
* issue_2385 add tests for iob_to_biluo converter function

* issue_2385 fix and modify iob_to_biluo function to accept either iob or biluo tags in cli.converter

* issue_2385 add test to fix b char bug

* add contributor agreement

* fill contributor agreement
2018-05-30 12:28:44 +02:00

35 lines
1.1 KiB
Python

# coding: utf-8
import pytest
from ...gold import iob_to_biluo
@pytest.mark.xfail
@pytest.mark.parametrize('tags', [('B-ORG', 'L-ORG'),
('B-PERSON', 'I-PERSON', 'L-PERSON'),
('U-BRAWLER', 'U-BRAWLER')])
def test_issue2385_biluo(tags):
"""already biluo format"""
assert iob_to_biluo(tags) == list(tags)
@pytest.mark.xfail
@pytest.mark.parametrize('tags', [('B-BRAWLER', 'I-BRAWLER', 'I-BRAWLER')])
def test_issue2385_iob_bcharacter(tags):
"""fix bug in labels with a 'b' character"""
assert iob_to_biluo(tags) == ['B-BRAWLER', 'I-BRAWLER', 'L-BRAWLER']
@pytest.mark.xfail
@pytest.mark.parametrize('tags', [('I-ORG', 'I-ORG', 'B-ORG')])
def test_issue2385_iob1(tags):
"""maintain support for iob1 format"""
assert iob_to_biluo(tags) == ['B-ORG', 'L-ORG', 'U-ORG']
@pytest.mark.xfail
@pytest.mark.parametrize('tags', [('B-PERSON', 'I-PERSON', 'B-PERSON')])
def test_issue2385_iob2(tags):
"""maintain support for iob2 format"""
assert iob_to_biluo(tags) == ['B-PERSON', 'L-PERSON', 'U-PERSON']