'Takes the json examples and switches them to a format which crfsuite likes.'

def _from_json_to_crf(self, message, entity_offsets):

    from spacy.gold import GoldParse
    doc = message.get(u'spacy_doc')
    gold = GoldParse(doc, entities=entity_offsets)
    ents = [l[5] for l in gold.orig_annot]
    if (u'-' in ents):
        logger.warn(((u"Misaligned    entity    annotation    in    sentence    '{}'.    ".format(doc.text) + u'Make    sure    the    start    and    end    values    of    the    annotated    training    ') + u"examples    end    at    token    boundaries    (e.g.    don't    include    trailing    whitespaces)."))
    if (not self.BILOU_flag):
        for (i, entity) in enumerate(ents):
            if (entity.startswith(u'B-') or entity.startswith(u'I-') or entity.startswith(u'U-') or entity.startswith(u'L-')):
                ents[i] = entity[2:]
    return self._from_text_to_crf(message, ents)
