Example #1
0
    def test_drop(self):
        pc = PatternCreator()

        pc.add("ET1", "hello")
        pc.add("ET1", "there")
        pc.add("ET2", "world")
        pc.add("ET4", "dog")

        assert pc.to_df().index.to_list() == [0, 1, 2, 3]

        pc.drop([1, 2])

        assert pc.to_df().index.to_list() == [0, 1]
Example #2
0
    def test_call(self):
        pc = PatternCreator()

        pc.add("new_entity_type", "tall")

        text = "I saw a tall building."
        doc = pc(text)
        assert len(doc.ents) == 1
        assert list(doc.ents)[0].label_ == "new_entity_type"

        pc.drop(0)

        doc2 = pc(text)

        assert len(doc2.ents) == 0