def test_repeated_entities():
    data = '\n{\n  "rasa_nlu_data": {\n    "common_examples" : [\n      {\n        "text": "book a table today from 3 to 6 for 3 people",\n        "intent": "unk",\n        "entities": [\n          {\n            "entity": "description",\n            "start": 35,\n            "end": 36,\n            "value": "3"\n          }\n        ]\n      }\n    ]\n  }\n}'
    with tempfile.NamedTemporaryFile(suffix='_tmp_training_data.json') as f:
        f.write(data.encode('utf-8'))
        f.flush()
        td = training_data.load_data(f.name)
        assert (len(td.entity_examples) == 1)
        example = td.entity_examples[0]
        entities = example.get('entities')
        assert (len(entities) == 1)
        tokens = WhitespaceTokenizer().tokenize(example.text)
        (start, end) = MitieEntityExtractor.find_entity(entities[0], example.text, tokens)
        assert (start == 9)
        assert (end == 10)
def test_repeated_entities():
    data = '\n{\n  "rasa_nlu_data": {\n    "common_examples" : [\n      {\n        "text": "book a table today from 3 to 6 for 3 people",\n        "intent": "unk",\n        "entities": [\n          {\n            "entity": "description",\n            "start": 35,\n            "end": 36,\n            "value": "3"\n          }\n        ]\n      }\n    ]\n  }\n}'
    with tempfile.NamedTemporaryFile(suffix='_tmp_training_data.json') as f:
        f.write(data.encode('utf-8'))
        f.flush()
        td = training_data.load_data(f.name)
        assert (len(td.entity_examples) == 1)
        example = td.entity_examples[0]
        entities = example.get('entities')
        assert (len(entities) == 1)
        tokens = WhitespaceTokenizer().tokenize(example.text)
        (start, end) = MitieEntityExtractor.find_entity(entities[0], example.text, tokens)
        assert (start == 9)
        assert (end == 10)