From 44fbdc7260a08793bc0daae6eff534d7570549f7 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Sun, 8 Nov 2015 16:19:12 +0100 Subject: [PATCH] * Fix bug in NER transition system, that sometimes left no valid moves --- spacy/syntax/ner.pyx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spacy/syntax/ner.pyx b/spacy/syntax/ner.pyx index c23fa8148..806050dc4 100644 --- a/spacy/syntax/ner.pyx +++ b/spacy/syntax/ner.pyx @@ -170,6 +170,9 @@ cdef class Begin: return False elif preset_ent_iob == 3 and st.B_(0).ent_type != label: return False + # If the next word is B or O, we can't B now + elif st.B_(1).ent_iob == 2 or st.B_(1).ent_iob == 3: + return False # Don't allow entities to extend across sentence boundaries elif st.B_(1).sent_start: return False