@@ -0,0 +1,2256 @@
+from __future__ import unicode_literals%0A%0Aimport pytest%0A%0Afrom ...vocab import Vocab%0Afrom ...syntax.ner import BiluoPushDown%0Afrom ...gold import GoldParse%0Afrom ...tokens import Doc%0A%0A%0A@pytest.fixture%0Adef vocab():%0A    return Vocab()%0A%0A%0A@pytest.fixture%0Adef doc(vocab):%0A    return Doc(vocab, words=%5B'Casey', 'went', 'to', 'New', 'York', '.'%5D)%0A%0A%0A@pytest.fixture%0Adef entity_annots(doc):%0A    casey = doc%5B0:1%5D%0A    ny = doc%5B3:5%5D%0A    return %5B(casey.start_char, casey.end_char, 'PERSON'),%0A            (ny.start_char, ny.end_char, 'GPE')%5D%0A%0A%0A@pytest.fixture%0Adef entity_types(entity_annots):%0A    return sorted(set(%5Blabel for (s, e, label) in entity_annots%5D))%0A%0A%0A@pytest.fixture%0Adef tsys(vocab, entity_types):%0A    actions = BiluoPushDown.get_actions(entity_types=entity_types)%0A    return BiluoPushDown(vocab.strings, actions)%0A%0A%0Adef test_get_oracle_moves(tsys, doc, entity_annots):%0A    gold = GoldParse(doc, entities=entity_annots)%0A    tsys.preprocess_gold(gold)%0A    act_classes = tsys.get_oracle_sequence(doc, gold)%0A    names = %5Btsys.get_class_name(act) for act in act_classes%5D%0A    assert names == %5B'U-PERSON', 'O', 'O', 'B-GPE', 'L-GPE', 'O'%5D%0A%0Adef test_get_oracle_moves_negative_entities(tsys, doc, entity_annots):%0A    entity_annots = %5B(s, e, '!' + label) for s, e, label in entity_annots%5D%0A    gold = GoldParse(doc, entities=entity_annots)%0A    for i, tag in enumerate(gold.ner):%0A        if tag == 'L-!GPE':%0A            gold.ner%5Bi%5D = '-'%0A    tsys.preprocess_gold(gold)%0A    act_classes = tsys.get_oracle_sequence(doc, gold)%0A    names = %5Btsys.get_class_name(act) for act in act_classes%5D%0A%0A%0Adef test_get_oracle_moves_negative_entities2(tsys, vocab):%0A    doc = Doc(vocab, words=%5B'A', 'B', 'C', 'D'%5D)%0A    gold = GoldParse(doc, entities=%5B%5D)%0A    gold.ner = %5B'B-!PERSON', 'L-!PERSON', 'B-!PERSON', 'L-!PERSON'%5D%0A    tsys.preprocess_gold(gold)%0A    act_classes = tsys.get_oracle_sequence(doc, gold)%0A    names = %5Btsys.get_class_name(act) for act in act_classes%5D%0A%0A%0Adef test_get_oracle_moves_negative_O(tsys, vocab):%0A    doc = Doc(vocab, words=%5B'A', 'B', 'C', 'D'%5D)%0A    gold = GoldParse(doc, entities=%5B%5D)%0A    gold.ner = %5B'O', '!O', 'O', '!O'%5D%0A    tsys.preprocess_gold(gold)%0A    act_classes = tsys.get_oracle_sequence(doc, gold)%0A    names = %5Btsys.get_class_name(act) for act in act_classes%5D%0A

Add test for NER