def pretty_print(text, tags): spans = [] for s, e, tag in bio_to_spans(text, tags): spans.append({"start": s, "end": e, "type": tag}) ents = dict((obj["type"].lower(), obj) for obj in spans).keys() ret = { "doc_text": " ".join(text), "annotation_set": list(ents), "spans": spans, "title": "None", } print({"doc": ret, "type": "high_level"}) return {"doc": ret, "type": "high_level"}
def pretty_print(text, tags): spans = [] for s, e, tag in bio_to_spans(text, tags): spans.append({'start': s, 'end': e, 'type': tag}) ents = dict((obj['type'].lower(), obj) for obj in spans).keys() ret = { 'doc_text': ' '.join(text), 'annotation_set': list(ents), 'spans': spans, 'title': 'None' } print({"doc": ret, 'type': 'high_level'}) return {"doc": ret, 'type': 'high_level'}
def display_results(text_str, predictions, intent_type): ret = { "annotation_set": [], "doc_text": " ".join([t for t in text_str]) } spans = [] available_tags = set() for s, e, tag in bio_to_spans(text_str, predictions): spans.append({"start": s, "end": e, "type": tag}) available_tags.add(tag) ret["annotation_set"] = list(available_tags) ret["spans"] = spans ret["title"] = intent_type return {"doc": ret, "type": "high_level"}
def display_results(text_str, predictions, intent_type): ret = { 'annotation_set': [], 'doc_text': ' '.join([t for t in text_str]) } spans = [] available_tags = set() for s, e, tag in bio_to_spans(text_str, predictions): spans.append({'start': s, 'end': e, 'type': tag}) available_tags.add(tag) ret['annotation_set'] = list(available_tags) ret['spans'] = spans ret['title'] = intent_type return {'doc': ret, 'type': 'high_level'}